Android Studio Error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"
The error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8" occurs when your project is using an older Java version. To fix it, upgrade to Java 11.
Make sure that your Gradle is using the proper JDK. Try running ./gradlew --version
in your project's directory. The output should be something like this:
Gradle 7.0-rc-2
------------------------------------------------------------
Build time: 2021-04-01 21:26:39 UTC
Revision: 912a3368b654b71250dfc925a20d620393
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.10 (Ubuntu 11.0.10+9-Ubuntu-0ubuntu1.20.10)
OS: Linux 5.11.4-051104-generic amd64
If the JVM points to version 1.8 then you should change it in settings. You can find it in Preferences → Build, Execution, Deployment → Build Tools → Gradle → *Gradle JDK.
To resolve the "Android Gradle plugin requires Java 11 to run" error, you need to upgrade your Java version from Java 1.8 to Java 11.
This can be done by installing Java 11, setting the appropriate JDK path in Android Studio, and ensuring your project’s Gradle files are configured to work with Java 11.
Once you update the Java version, your project will be able to build and run without issues. This step is necessary because recent versions of the Android Gradle plugin require Java 11 to support newer features, performance improvements, and compatibility with updated dependencies.