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.
For 0.60, React Native has been migrated over to AndroidX. This is a breaking change, and your native code and dependencies will need to be migrated as well. With this change, React Native apps will need to begin using AndroidX themselves.
Visit the web page https://developer.android.com/studio/ and download android studio. After downloading the installation file of it, double click on it and proceed with the installation.
React Native App supports only 400 Android devices and Android 11 or + - Stack Overflow.
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.
In this file android/gradle/wrapper/gradle-wrapper.properties change distributionUrl on this distributionUrl=https://services.gradle.org/distributions/gradle-6.0-all.zip
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With