react-native
react-native copied to clipboard
fix detection of android emulator
Summary
at some point, the Build.FINGERPRINT
of the emulator has changed and no longer includes generic
as an option.
It apparently now, on all platforms, includes google/sdk_gphone
at the beginning. Older emulators may still include generic
in the Build.FINGERPRINT
so we should maintain that check too.
Changelog
[Android] [Fixed] - Fix android emulator detection for packager host
Test Plan
When running on a modern emulator, ensure that the packager attempts to load from 10.0.2.2
.
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
android | hermes | arm64-v8a | 7,003,414 | +258 |
android | hermes | armeabi-v7a | 6,379,746 | +253 |
android | hermes | x86 | 7,416,244 | +255 |
android | hermes | x86_64 | 7,280,146 | +251 |
android | jsc | arm64-v8a | 8,868,429 | +151 |
android | jsc | armeabi-v7a | 7,606,752 | +159 |
android | jsc | x86 | 8,926,325 | +137 |
android | jsc | x86_64 | 9,409,569 | +146 |
Base commit: 6a43fafd78d581f63c664b9af6d10828ac7f77fa Branch: main
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
ios | - | universal | n/a | -- |
Base commit: 76f70849578c664e9b14d96475e30e179edd7222 Branch: main
PR build artifact for 53fd80a5f209df28e125020eb442d698dec30a54 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
Thanks for sending this @deecewan Was this tested? Could you provide a screenshot of your emulator where to local host is properly shown to 10.0.2.2?
Hey @cortinico - I tested this using the debugger to ensure that the isRunningOnStockEmulator
method returns true
for the Build.FINGERPRINT
of the simulator I was running. It didn't before the change, it does afterwards.
Here's a screenshot of the getServerIpAddress
running in the debugger with the changes.

I ran this by patching the file in my node_modules
, then switching out the maven dependency on react-native
for the ReactAndroid
implementation containing the patch.
@GijsWeterings has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.