Skip to content
Advertisement

Error with react-native run-android after upgrade to react-native version 0.60.4

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement