Android Gradle Plugin Requires Java 11
Problem
When building Android projects with newer versions of Android Studio and the Android Gradle plugin, you may encounter the following error:
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.This error occurs because newer versions of the Android Gradle plugin (version 7.0.0 and above) require Java 11 or later, while your development environment is configured to use Java 1.8 (Java 8).
Solutions
Method 1: Configure Gradle JDK in Android Studio (Recommended)
The simplest solution for most users is to update the Gradle JDK setting directly in Android Studio:
- Open Preferences (macOS) or Settings (Windows/Linux)
- Navigate to Build, Execution, Deployment → Build Tools → Gradle
- Under Gradle JDK, select a Java 11 or later JDK
- Click OK and rebuild your project

Method 2: Set Java Home in gradle.properties
If the IDE setting doesn't work or you need to configure this for command-line builds:
- Open your project's
gradle.propertiesfile - Add the following line with the correct path to your JDK 11 installation:
# macOS
org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
# Windows
org.gradle.java.home=C:\Program Files\Java\jdk-11.0.15
# Linux
org.gradle.java.home=/usr/lib/jvm/java-11-openjdk-amd64Method 3: Update Environment Variables
For command-line builds and terminal usage:
macOS/Linux
Add to your shell profile (~/.bash_profile, ~/.zshrc, etc.):
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"Reload your shell configuration:
source ~/.zshrc # or ~/.bash_profileWindows
- Open System Properties → Environment Variables
- Create or update the
JAVA_HOMEvariable to point to your JDK 11 installation - Add
%JAVA_HOME%\binto yourPATHvariable - Restart your terminal/IDE
Method 4: Check Global Gradle Configuration
Sometimes a global Gradle configuration overrides your project settings. Check for a global gradle.properties file at:
- macOS/Linux:
~/.gradle/gradle.properties - Windows:
C:\Users\<username>\.gradle\gradle.properties
Remove or update any org.gradle.java.home entries that might be forcing Java 8.
Platform-Specific Solutions
For Flutter Projects
Add the Java home path to your android/gradle.properties file:
org.gradle.java.home=/path/to/jdk-11For CI/CD Pipelines
GitHub Actions
Update your workflow to use JDK 11:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11Azure DevOps
Add this task to your pipeline:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'MS App Center
Set the environment variable in build configuration:
JAVA_HOME=$(JAVA_HOME_11_X64)
Verification
After applying any solution, verify that Gradle is using the correct Java version:
cd android # For React Native/Flutter projects
./gradlew --versionLook for the JVM version in the output:
JVM: 11.0.12 (JetBrains s.r.o. 11.0.12+0-b1504.28-7817840)Alternative: Downgrade Android Gradle Plugin
If you cannot upgrade to Java 11, you can downgrade the Android Gradle plugin (not recommended for new projects):
// In your project-level build.gradle
plugins {
id 'com.android.application' version '4.2.0' apply false
id 'com.android.library' version '4.2.0' apply false
}WARNING
Downgrading the Android Gradle plugin may limit your access to newer Android features and optimizations.
Troubleshooting
- Paths with spaces: On Windows, use the short path format (
Progra~1instead ofProgram Files) or escape spaces properly - Multiple JDK installations: Use
java -XshowSettings:properties -versionto identify all installed JDKs - Android Studio bundled JDK: Recent versions include a compatible JDK at
Android Studio.app/Contents/jbr/Contents/Home(macOS)
Conclusion
The "Android Gradle plugin requires Java 11" error is resolved by ensuring your build environment uses Java 11 or later. The recommended approach is to configure the Gradle JDK in Android Studio settings or set the org.gradle.java.home property in your gradle.properties file. For CI/CD environments, ensure your build agents are configured with the correct Java version.