i built a react native app and integrated it with firebase. it works fine in ios when i run with npx react-native run-ios. It even works in android if i open the project directly in android studio and run it. but when i run the command run-android i get the error below:
npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1153 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
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 932ms
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
npm ERR! code 1
npm ERR! path /Users/manishshukla/Documents/technical/mytestapp
npm ERR! command failed
npm ERR! command sh -c react-native run-android
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/manishshukla/.npm/_logs/2020-12-06T21_55_04_212Z-debug.log
basically gradle-6.3 did the trick. when i set up everything it was 6.2. in gradle-wrapper.properties i had to change 6.2 to 6.3 like this:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
try running npx react-native doctor in your project's directory terminal and when you got the error just press e inside your terminal and it will install/upgrade your files according to it
Related
HELP!!... I can't run a newly generated react native app with npm run android, I already tried the following: /gradlew clean, made sure the emulator is up and running, I also tried to install the ndk, but I'm not sure how I'm supposed to select it.
✘ dio#pop-os ~/Documents/Code/Beex-Travel/beexmobile developing npm run android
> beexmobile#0.0.1 android /home/dio/Documents/Code/Beex-Travel/beexmobile
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1096 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
> Task :app:stripDebugDebugSymbols FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
25 actionable tasks: 2 executed, 23 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
* 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 15s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beexmobile#0.0.1 android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beexmobile#0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dio/.npm/_logs/2021-03-15T08_03_34_370Z-debug.log
Try installing Android NDK. There should be clear instructions how to do this for your platform. Then put the directory where you have the executables that have the fine name starting with ’arm-linux-androideabi’ in your PATH. Make sure you can run ’arm-linux-androideabi-gcc’ or any other thing you find in the ’bin’ directory. Then try and see if your ’npm’ build command proceeds further.
I created a new project with React Native in Windows 10 but it does not run with the run-android command.
I will summarize what I did because I think all the programs are installed:
I install both npm and node.
Java installation.
React installation.
In the Environment system, these are set.
ANDROID_HOME ---> C:\Users\IHC\AppData\Local\Android\Sdk
JAVA_HOME--> C:\Program Files\Java\jdk-۱۴.۰.۱
path--> C:\Users\IHC\AppData\Local\Android\Sdk\tools
C:\Users\IHC\AppData\Local\Android\Sdk\platform-tools
C:\Program Files\nodejs\
C:\Users\IHC\AppData\Local\Android\Sdk
C:\Users\IHC\AppData\Local\Android\Sdk\emulator
C:\Program Files\Java\jdk-۱۴.۰.۱\bin
The error is:
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
.
.
.
.
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:832)
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
* 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 44s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
enter code here
Can you check on the android version installed, for latest version refer https://www.npmjs.com/package/#react-native-community/cli-platform-android and retry.
That is installed, well I did the following
remove jdk-۱۴.۰.۱ and i install jdk-8u261-windows-x64
first of all run Oracle VM VirtualBox next run Genymotion
and in powershell
npm start -- --reset-cache
npm install -g npm#4
react-native run-android
$ 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 4 workers...
info JS server already running.
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 669ms
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
But it was running perfectly on ios simulator only problem while running or android emulator
In gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
Complete Console Output is below
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 JS server already running.
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 696ms
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 696ms
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)
Bash_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
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
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
alias emulator='$ANDROID_SDK_ROOT/tools/emulator'
Requested Attachments
Android SDK Link From Android Studio
SDK Tools Installed
npx #react-native-community/cli doctor Result
Installed Android Emulator
Nexus 6P (Android R and Pie)
New To React Native
it works perfectly on iOS
but it fails to launch in Android Simulator
Tried Ways
npm start
npx react-native run-ios
npx react-native run-android
It is Probably because of JDK version as mention above.
You can verify by running react native doctor
npx #react-native-community/cli doctor
Install JDK 1.8 and setup $JAVA_HOME env variable and try to run the app again.
The error is due to lower version of JDK or JDK not installed.
your problem can be resolved just follow these steps:
To jetify / convert node_modules dependencies to AndroidX
Imagine you have a react-native project. One of your library dependencies converts to AndroidX., and you need to use the new version.
So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again
you can follow this link as well: https://www.npmjs.com/package/jetifier
feel free for any confusion.
This link is the complete solution but here is a little problem if you have win32 but if you have win64 you are good to go.
**https://www.npmjs.com/package/jetifier#do_you_need_this**
hope this answer will be useful for you
feel free for any problem.
The error is due to the version of JDK or JDK not installed.
i think you need to solve in the section:
open the androind folder with android studio
then file-> project structure -> SDK location
and in here you can change, in my case i change the version
before that, for to know what was the error:
i realized what is the problem with this command
npx #react-native-community/cli doctor
i got these errors:
Please make changes as per below to resolve this error.
Install Java SDK version: 14 or above.
JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
In gradle-wrapper.properties please use grade version 6.3 or above.
For e.g:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
I'm having trouble running the application inside the simulator
And gives the following error:
(I've tested on Genymotion and nox simulators)
none
C:\Users\Sajjad Alavi\Desktop\n\test1>npm run android
> # android C:\Users\Sajjad Alavi\Desktop\n\test1
> react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat ap
p:installDebug)...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Sajjad Alavi\Desktop\n\test1\android\app\build.gradle' line
: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : U
nsupported major.minor version 52.0
* 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
Deprecated Gradle features were used in this build, making it incompatible with
Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:com
mand_line_warnings
BUILD FAILED in 6s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag
for more details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # android script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sajjad Alavi\AppData\Roaming\npm-cache\_logs\2019-09-11T16
_13_49_689Z-debug.log
Seems you are using the wrong version of JDK. Check your JAVA_HOME to use JDK 1.8
you should go to
user >> program_data >> gradle
Delete the cache
then,run the program in android studio