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 : Getting rid of stack traces during run-android by using CLIError #1891

Merged

Conversation

arushikesarwani94
Copy link
Contributor

@arushikesarwani94 arushikesarwani94 commented Mar 27, 2023

Summary:

As highlighted in #1766, there are useless stack traces in errors during run-android that are meant to be human-readable. Hence utilizing CLIError of it's ability to strip out the stack trace in such cases.

This workflow is part of the onboarding experience of RN, there by this would improve DevX

Test Plan:

  1. Build cli codebase using : node ./scripts/build.js && yarn build:debugger.
  2. cd packages/cli-platform-android
  3. Link packages using : yarn link
  4. In RN app AwesomeProject, run yarn link "@react-native-community/cli-platform-android" to see successful linking :
arushikesarwani@arushikesarwani-mbp AwesomeProject % yarn link "@react-native-community/cli-platform-android"
yarn link v1.22.19
warning ../package.json: No license field
success Using linked package for "@react-native-community/cli-platform-android".
✨  Done in 0.02s.
arushikesarwani@arushikesarwani-mbp AwesomeProject % 
  1. react-native run-android

BEFORE :

arushikesarwani@arushikesarwani-mbp AwesomeProject % react-native run-android                                  
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: The emulator (Pixel_5_API_33) quit before it finished opening. You can try starting the emulator manually from the terminal with: /opt/android_sdk/emulator/emulator @Pixel_5_API_33.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.


error Failed to install the app. Command failed: ./gradlew tasks
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Error: Command failed: ./gradlew tasks
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.



    at makeError (/Users/arushikesarwani/cli/node_modules/execa/index.js:174:9)
    at module.exports.sync (/Users/arushikesarwani/cli/node_modules/execa/index.js:338:15)
    at getGradleTasks (/Users/arushikesarwani/cli/packages/cli-platform-android/build/commands/runAndroid/listAndroidTasks.js:53:32)
    at getTaskNames (/Users/arushikesarwani/cli/packages/cli-platform-android/build/commands/runAndroid/getTaskNames.js:21:73)
    at runOnAllDevices (/Users/arushikesarwani/cli/packages/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:61:55)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.handleAction (/Users/arushikesarwani/cli/packages/cli/build/index.js:111:9)
info Run CLI with --verbose flag for more details.
arushikesarwani@arushikesarwani-mbp AwesomeProject % 

AFTER :

arushikesarwani@arushikesarwani-mbp AwesomeProject % react-native run-android                                
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: The emulator (Pixel_5_API_33) quit before it finished opening. You can try starting the emulator manually from the terminal with: /opt/android_sdk/emulator/emulator @Pixel_5_API_33.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.


error Failed to install the app. Command failed: ./gradlew tasks
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
info Run CLI with --verbose flag for more details.
arushikesarwani@arushikesarwani-mbp AwesomeProject % 

@arushikesarwani94 arushikesarwani94 marked this pull request as ready for review March 27, 2023 21:00
@thymikee thymikee merged commit abbec76 into react-native-community:main Mar 27, 2023
@arushikesarwani94 arushikesarwani94 deleted the android_cli_error branch March 27, 2023 21:22
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.

2 participants