Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix detection of android emulator #35111

Closed

Conversation

deecewan
Copy link
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

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

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

Base commit: 76f7084
Branch: main

@pull-bot
Copy link

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
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
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
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
Contributor

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

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
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

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Fix android emulator detection for packager host

Pull Request resolved: facebook#35111

Test Plan: When running on a modern emulator, ensure that the packager attempts to load from `10.0.2.2`.

Reviewed By: cipolleschi

Differential Revision: D41266071

Pulled By: GijsWeterings

fbshipit-source-id: 43115dbde6a411fe2ebde23e720dff4812a4309f
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