Error with react-native run-android after upgrade to react-native version 0.60.4
Solution 1
Looks like Gradle is currently erroring on builds using openJDK-13.
Here's a Github issue thread.
Check the version of Java and JDK versions on your system by running the following command on in your terminal:
file /etc/alternatives/java /etc/alternatives/javac
OR
file `which java javac`
This will list the current installations on your system. If you see openjdk-13
anywhere, you'll have to downgrade to openjdk-8
.
Check this link for downgrading steps.
Solution 2
For those who are here for java.lang.IllegalArgumentException: Unsupported class file major version 60
One of the reason for the same is:
Java version 16 installed which is not yet supported by react-native.
So For MacOS,
cd /Library/Java/JavaVirtualMachines
ls
-
Check the available JDKs
-
Remove the jdk-16 if present using this,
sudo rm -rf jdk-16.jdk/
Basically, you can remove JDKs other than adoptopenjdk-8.jdk
which will be present if you followed React-Native Env Setup.
Solution 3
In this file android/gradle/wrapper/gradle-wrapper.properties change distributionUrl on this distributionUrl=https://services.gradle.org/distributions/gradle-6.0-all.zip
Keannylen
Updated on July 24, 2022Comments
-
Keannylen almost 2 years
I am upgrading react-native from 0.59.5 to 0.60.4 with my existing application. But facing a problem as below
* Where: Build file '/home/bingl/Projects/blackstar/frontend/android/app/build.gradle' * What went wrong: Could not compile build file '/home/bingl/Projects/blackstar/frontend/android/app/build.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(ClassNodeReso
And my build.gradle is
android { compileSdkVersion 28 buildToolsVersion "28.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.frontend" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } buildTypes { release { minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } }
I have absolutely no clue what this error is about and could not find much helpful articles. Please help me out.
-
Keannylen over 4 yearsYou right, it solves this problem and another coming, looks like I upgrade too early.
-
LincyTonita almost 3 yearsYes I too face this issue with java 16. Which version is compatible? Do you have any idea?
-
Shreyansh almost 3 years@LincyTonita I have mentioned the name of compatible JDK. It is 1.8.0_282 right now, but you can always check react-native env link mentioned for the updated one.
-
LincyTonita almost 3 yearsThank you so much.
-
Naycho334 over 2 yearsIt works for me, thank you!