---
title: "How do you fix the JVM target incompatibility error in a React Native Android build?"
description: "The Java and Kotlin compile tasks target different JVM versions. Align compileOptions and kotlinOptions, or the Gradle JDK, in the Android project."
url: "https://bugsee.com/answers/react-native/fix-jvm-target-incompatibility/"
---

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

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.

```groovy
// 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

- [How do you clear the Metro bundler cache in React Native?](https://bugsee.com/answers/react-native/clear-the-metro-cache/)
