Skip to content

fix detection of android emulator#35111

Closed
deecewan wants to merge 1 commit into
facebook:mainfrom
deecewan:fix/android-emulator-detection
Closed

fix detection of android emulator#35111
deecewan wants to merge 1 commit into
facebook:mainfrom
deecewan:fix/android-emulator-detection

Conversation

@deecewan
Copy link
Copy Markdown
Contributor

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.

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.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 28, 2022
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Oct 28, 2022
@analysis-bot
Copy link
Copy Markdown

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: 6a43faf
Branch: main

@analysis-bot
Copy link
Copy Markdown

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 76f7084
Branch: main

@pull-bot
Copy link
Copy Markdown

PR build artifact for 53fd80a 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.

@cortinico
Copy link
Copy Markdown
Contributor

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?

@deecewan
Copy link
Copy Markdown
Contributor Author

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.

Screenshot 2022-10-29 at 1 31 49 pm

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.

Copy link
Copy Markdown
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cipolleschi can you import this one?

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@GijsWeterings has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Platform: Android Android applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants