npx react-native run-android Failing in macOS
See original GitHub issue- I Had Setup Android Studio installed in Mac
- I had installed ADB Nexus 6p (R and Android Pie)
- Tried Manually Running Android Emulator - Works Perfect
AVD Manager:
Nexus 6p with Android R and Android Pie
Installed SDK:
SDK Platforms
bash_profile or bashrc
Command Used: nano .bash_profile
export ANDROID_HOME=/Users/user/Library/Android/sdk
export PATH=${PATH}:/Users/user/Library/Android/sdk/tools
export PATH=${PATH}:/Users/user/Library/Android/sdk/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Command used: npx @react-native-community/cli doctor
user@Devs-Mac MyReactApp % npx @react-native-community/cli doctor
Common
✓ Node.js
✓ yarn
✓ Watchman - Used for watching changes in the filesystem when in development mode
Android
✓ JDK
✖ ANDROID_HOME
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 28.0.3
iOS
✓ Xcode - Required for building and installing your app on iOS
✓ CocoaPods - Required for installing iOS dependencies
✓ ios-deploy - Required for installing your app on a physical device with the CLI
Command used: npx react-native run-android
user@Devs-Mac MyReactApp % npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
/bin/sh: adb: command not found
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...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 748ms
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 748ms
at makeError (/Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:174:9)
at /Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli/build/index.js:186:9)
File local.properties inside android folder of React-native project
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Apr 21 17:57:13 IST 2020
sdk.dir=/Users/user/Library/Android/sdk
Command: react-native info Environment Information
user@Devs-Mac MyReactApp % react-native info
info Fetching system and libraries information...
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
Memory: 8.14 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6308749
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
Languages:
Java: 14.0.1 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Even ran brew cask install android-sdk Just to make it work Logs Below
user@Devs-Mac ~ % brew cask install android-sdk
Updating Homebrew...
==> Caveats
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:
'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'
android-sdk requires Java 8. You can install it with:
brew cask install homebrew/cask-versions/adoptopenjdk8
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'android-sdk'.
==> Installing Cask android-sdk
==> Linking Binary 'android' to '/usr/local/bin/android'.
==> Linking Binary 'archquery' to '/usr/local/bin/archquery'.
==> Linking Binary 'avdmanager' to '/usr/local/bin/avdmanager'.
==> Linking Binary 'jobb' to '/usr/local/bin/jobb'.
==> Linking Binary 'lint' to '/usr/local/bin/lint'.
==> Linking Binary 'monkeyrunner' to '/usr/local/bin/monkeyrunner'.
==> Linking Binary 'screenshot2' to '/usr/local/bin/screenshot2'.
==> Linking Binary 'sdkmanager' to '/usr/local/bin/sdkmanager'.
==> Linking Binary 'uiautomatorviewer' to '/usr/local/bin/uiautomatorviewer'.
==> Linking Binary 'emulator' to '/usr/local/bin/emulator'.
==> Linking Binary 'emulator-check' to '/usr/local/bin/emulator-check'.
==> Linking Binary 'mksdcard' to '/usr/local/bin/mksdcard'.
==> Linking Binary 'monitor' to '/usr/local/bin/monitor'.
🍺 android-sdk was successfully installed!
Issue Still same
Issue Analytics
- State:
- Created 3 years ago
- Comments:30
Top Results From Across the Web
react-native run-android Fails MacOS - Stack Overflow
First, use Android Studio's refactoring tool to convert your app re: ... --save-dev jetifier npx jetify npx react-native run-android (your ...
Read more >React Native Android : FAILURE: Build failed with an ...
This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, follow...
Read more >npx react-native run-android build failed - You.com
My colleague recently added react-native-camera to my project. I merged the code and when i run npx react-native run-android my build fails with:...
Read more >Troubleshooting - React Native
If you run into issue where executing npm run android on macOS throws the above error, try to run sudo chmod +x android/gradlew...
Read more >Setting up ReactNative on Mac OSX + Apple Silicon - nish abe
cd "AwesomeTSProject" && npx react-native run-android. For me, this resulted in an error as below: What happens here is certain tasks need Java11,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RockinGarg i hope it helps you
1、open a terminal 2、
touch ~/.bash_profile
3、open ~/.bash_profile
4、write5、source ~/.bash_profile(if it doesn’t work,next) 6、change
"android": "react-native run-android"
to"android": "source ~/.bash_profile&&react-native run-android"
, and runyarn android
This is happening for me too. It was all working fine yesterday, I could run my RN app on both iOS and Android. Today however, I’m getting this error from Android when using
npx react-native run-android
:Doing
npx react-native doctor
gives:I followed the installation instructions to the T, and it was all working correctly yesterday. That suggests to me there’s something up with the environment variables but I can’t work out what it is. Here’s my
.bash_profile
:Running
source ~/.bash_profile && npx react-native doctor
gives the same output as above.