Reputation: 186
I am trying to run react-native with the CLI method. I also got the react-native-vector-icons and linked it to react native as following this tutorial from traversy media - https://www.youtube.com/watch?v=Hf4MJH0jDb4&t=933s. I had android studio installed and also Gradle all updated to the latest version.
Java Version
java 14.0.1 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
What cmd says the problem is.
* 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
This is what I am getting in my cmd. What is the problem? This is my entire console when I run the command to start with the above included.
C:\Users\Devesh\ShoppingList>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 Starting JS server...
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 864ms
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
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 864ms
at makeError (C:\Users\Devesh\ShoppingList\node_modules\execa\index.js:174:9)
at C:\Users\Devesh\ShoppingList\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:\Users\Devesh\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\Devesh\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)
The android emulator launches but does not load the react app or anything, just plain emulator and the react CLI in another window. Did someone else run into this problem too? Do you know how to fix this?
Upvotes: 1
Views: 5091
Reputation: 328
Change gradle to 6.3.
I modified the file android/gradle/wrapper/gradle-wrapper.properties
and set distributionUrl to https\://services.gradle.org/distributions/gradle-6.3-all.zip
Just 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
Upvotes: 10
Reputation: 186
I found out what the problem was. Because the Gradle 6.3 is not properly supporting the JDK 14, I got the JDK 11 LTS installed. Then got the CLI updated with
npm install @react-native-community/cli
Then trashed the old project. init a new one and it worked. It might not be the optimal solution for others but worked for me as I was just getting started.
Upvotes: 2