react-native: Hi! I created new react native project and I can't build on android
React Native version:
"dependencies": { "react": "16.9.0", "react-native": "0.61.1" }
MacOS: 10.14.6 Java JDK: 13
Action:
- react-native init AwesomeProject
- cd AwesomeProject
- react-native run-android
Error: FAILURE: Build failed with an exception.
-
Where: Settings file ‘/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle’
-
What went wrong: Could not compile settings file ‘/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle’.
startup failed: General error during semantic analysis: Unsupported class file major version 57
java.lang.IllegalArgumentException: Unsupported class file major version 57 at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:184) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:152) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:273) at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81) at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:254) at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:192) … ETC … at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.base/java.lang.Thread.run(Thread.java:830)
1 error
-
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 432ms
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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
- Where: Settings file ‘/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle’ …
HELP ME PLEASE
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 22 (3 by maintainers)
Go to
android/gradle/wrapper/gradle-wrapper.properties
Change the following line:
That’s what worked for me with the latest versions of everything on MacOS
@lichcse
In your android/build.gradle, do you have
maven { url "https://jitpack.io" }
?If so change it to
maven { url "https://www.jitpack.io" }
an try running the project again.For others reading, it’s not that JDK 13 is buggy, it’s that the packaged version of gradle doesn’t support it, you either have to downgrade your JDK version, or as @MaffooBristol suggested instruct the build to use a newer version of gradle that does support Java 13.
@razr130 You can download JDK 1.8 at https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Next step switch version: https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x
Good luck to you
I’m having the same issue I believe.
[Update]: Solved my issue. I initiated the app using version 0.57 rather than 0.61, and that got me over the gradle issue. I then ran it, and got a new error about my JDK version. I switch to OpenJDK8 rather than JDK 13 and that seemed to work. Seems to work.
This issue is regarding OSX, but I ran into the same problem using Arch Linux. In case anyone else does as well here’s is how I fixed it:
This will downgrade from JDK13 to JDK11.
Hi @LMestre14 I did your recommend and I got same error. Hi @cjtaylor1990 I switched to JDK 1.8 and it worked. (keep react-native 0.61.1) Hi @dulmandakh I think this is a bug with java version 13.
Thanks to all bro
This Solution Actually works (Y) , JDK13 is buggy
Are there any downsides to manually changing this version? After all, it’s a major version change that RN itself would probably make itself in an upcoming release. What if there are conflicts on a future RN upgrade?
@paldepind You don’t see a fix specifically for Arch Linux very frequently. Thanks man 😃
I don’t know in the case of mac. i just changed the JAVA_HOME path variable to old JDK installation and it worked
No problem, @lichcse Took me all afternoon of messing around to finally figure that out. Yeah, since JDK 13 is really new, it wouldn’t surprise me if something broke. Yeah, once I switched to the older JDK, 0.61 worked fine. Glad I could help! =)
If you have Android Studio installed, JDK is already bundled inside the app. You don’t have to install it separately.
Simply set these two path when compiling should work,
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
~/Library/Android/sdk
Does JDK 12 works?
Same issue @lichcse had on MacOS, I had on Windows. React Native v.0.61.4, JDK v.13.0.1. Downgrading JDK to 11 removed the issue.
Hello @cjtaylor1990 could you tell me how to switch from java 13 to openJDK8 in mac? I did some uninstall and reinstall and not seems to succesed on switching the version. Thanks
Sure bro, rootProject.name = ‘AwesomeProject’ apply from: file(“…/node_modules/@react-native-community/cli-platform-android/native_modules.gradle”); applyNativeModulesSettingsGradle(settings) include ‘:app’
could you please share what’s in the Users/lichtv/workspace/react/src/FristApp/android/settings.gradle file?