How do you fix the JVM target incompatibility error in a React Native Android build?

← React Native answers

Make the Java and Kotlin compile tasks use the same JVM version, usually by setting compileOptions and kotlinOptions to the same value, or by running Gradle on a matching JDK.

The error says the Java task and the Kotlin task of a module are compiling for different targets, for example 1.8 and 11. It often appears after upgrading React Native, the Android Gradle Plugin or a library whose module sets its own target.

// android/app/build.gradle
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"
    }
}
  • Use the JDK version your React Native release expects; recent releases use 17.
  • Check JAVA_HOME and Android Studio's Gradle JDK setting so command-line and IDE builds agree.
  • If one library module is the culprit, fix its build.gradle, or use a version of the library that matches your toolchain.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required