Sentry Answers>React Native>

React Native: 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target incompatibility

React Native: 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target incompatibility

Matthew C.

The Problem

When using Expo or Android Studio IDE to build a React Native Android application, you get the following error:

Click to Copy
FAILURE: Build failed with an exception. Task :react-native-gradle-plugin:compileKotlin 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target

The problem occurs when the React Native Gradle plugin’s Java Virtual Machine (JVM) target compatibility check fails due to the use of inconsistent Java bytecode versions.

The Solution

Ensure the same Java version is used across your project:

  • Install Java Development Kit (JDK) version 11.
  • If you’ve already installed JDK, set the correct Java version on your computer.

Set the Correct Java Version on Your Computer

If you have multiple Java versions installed on your computer, including Java 11, ensure your JAVA_HOME environment variable points to the correct version.

If you’re using Windows, open the Command Prompt and run it as an administrator so you can add a system environment variable. Set the value of the JAVA_HOME environment variable to your JDK (or JRE) installation path:

Click to Copy
setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8"

If you’re using macOS, set the JAVA_HOME environment variable by adding the following line to your shell’s configuration file:

Click to Copy
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
  • Zsh is the default shell on macOS Catalina and later. The Zsh configuration file is saved as ~/.zshrc or ~/.zprofile.
  • The Bash configuration file is saved as ~/.bash_profile or ~/.bashrc.

Install JDK Version 11

React Native recommends you use the Homebrew package manager to install the version 11, Azul Zulu build of OpenJDK on macOS and use the popular Chocolatey package manager to install JDK version 11 on Windows.

Note: If you are using the latest version of React Native, version 0.75, React Native recommends you install JDK version 17, update the React Native version in your project, and update Android Studio if possible.

Pick a Different Base Image For Expo Application Services

If you are using Expo Application Services (EAS), you can specify a build image that includes JDK 11 in your eas.json file:

Click to Copy
{ "build": { "development": { "image": "ubuntu-22.04-jdk-11-ndk-r21e" } } }

Update Android Studio Gradle JDK

If you are using Android Studio, you may get the following error after installing or setting your JDK version to JDK 11:

Click to Copy
FAILURE: Build failed with an exception. Could not determine dependencies of task ':app:compileDebugJavaWithJavac'.

Fix this error by updating the Gradle JDK version:

  • Open the Android Studio Settings and use the navigation menu to go to Build, Execution, Deployment > Build Tools > Gradle in the navigation menu.
  • In the Gradle projects section, set the Gradle JDK to JDK version 11.0.12.

Note

The JDK contains everything you need to develop and run Java apps, including the JVM and tools for building your app. The JVM is an interpreter that executes Java applications.

React Native Android projects use both Java and Kotlin code:

  • The React Native Android runtime is written in Java.
  • The React Native Gradle plugin uses Kotlin and Java.

Gradle is a Java build tool used to compile Android apps; it needs to compile the Kotlin and Java code to compatible bytecode versions.

The initial error indicates that the project is trying to compile Java code targeting Java version 1.8 and Kotlin code targeting Java version 11, which Gradle doesn’t allow. Gradle requires consistent Java bytecode versions across your project.

  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2025 • Sentry is a registered Trademark of Functional Software, Inc.