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: run-android device not found on change from deviceId to device #2595

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

High5Apps
Copy link
Contributor

@High5Apps High5Apps commented Feb 11, 2025

Summary:

  • I have a script that uses npx react-native run-android --deviceId <deviceId>
  • When upgrading to React Native 75, I started seeing the following deprecation warning (line link) when using the script mentioned above:
    warn The `deviceId` parameter is renamed to `device`. Please use the new `device` argument next time to avoid this warning.
    
  • So I updated my script to use npx react-native run-android --device <deviceId>, to remove the deprecation warning. But then, instead of working as expected, I got the following error message (line link):
    error No Android device or emulator connected.
    
  • This issue was introduced in chore(run-android): deprecate --deviceId in favour of --device #2377
  • This PR fixes the error above, so that calling run-android with --device instead of --deviceId works as expected
  • The root cause was that the if statement in line 229 was always false because deviceId was never present, since --deviceId flag was no longer used
  • Basically this PR converts the remaining references to deviceId in runAndroid/index.ts to be device instead. Note that references to device.deviceId were unchanged to keep this PR as minimal as possible.

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Observe the current buggy behavior by running the following command
node /path/to/react-native-cli/packages/cli/build/bin.js run-android --device "<your_device_id>"
  1. Apply this patch and rebuild
  2. Re-run the command above and observe that the error is not shown, and that Android is built and run as expected
  3. Run the command below to verify that this PR didn't cause any regressions to run-android --list-devices
node /path/to/react-native-cli/packages/cli/build/bin.js run-android --list-devices

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@High5Apps High5Apps requested a review from cortinico as a code owner February 11, 2025 21:41
Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

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

good call! thanks for fixing 🙏 (and sorry for breaking 🙈)

@thymikee thymikee merged commit a46a903 into react-native-community:main Feb 12, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants