Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native run-android fails from terminal

Tags:

react-native

D:\ReactNative\AwesomeProject>react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 863 file(s) to forward-jetify. Using 4 workers... info Starting JS server... info Launching emulator... error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app... :ReactNative:Cannot run program "npx": CreateProcess error=2, The system cannot find the file specified :ReactNative:Automatic import of native modules failed.

FAILURE: Build failed with an exception.

  • Where: Script 'D:\ReactNative\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 169

  • What went wrong: A problem occurred evaluating script.

    Cannot invoke method getErrorStream() on null object

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • Where: Script 'D:\ReactNative\AwesomeProject\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 169

  • What went wrong: A problem occurred evaluating script.

    Cannot invoke method getErrorStream() on null object

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\ReactNative\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
like image 686
chandrakant Chaturvedi Avatar asked Oct 15 '19 19:10

chandrakant Chaturvedi


1 Answers

For me the problem was over this cli:

@react-native-community/cli-platform-android

The problematic version:

3.0.0-alpha.7

Just run this to install the latest stable release:

npm i @react-native-community/[email protected]

UPDATE 2020:

if this workaround doesn't work now, take a look over this link to use the latest version from the repo, and look the version of your cli to compare and use the correct one:

https://www.npmjs.com/package/@react-native-community/cli-platform-android
like image 139
HolloW Avatar answered Oct 15 '22 00:10

HolloW