Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. Error

I want to publish a library with Jitpackio. When I publish the library I get 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`."

Gradle Version : 7.0.2

My Gradle JDK Version

Can you help me?

like image 219
gokmenbayram Avatar asked Aug 01 '21 10:08

gokmenbayram


People also ask

Does Gradle support Java 11?

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.

Does Gradle 7 require Java 11?

A Java version between 8 and 18 is required to execute Gradle. Java 19 and later versions are not yet supported. Java 6 and 7 can still be used for compilation and forked test execution. Any supported version of Java can be used for compile or test.

Which Gradle works with Java 11?

The minimum version of Gradle that supports Java 11 is 5.0 . You would need to upgrade to version 7.0 or above for Android.


2 Answers

The problem was that JitPack.io was running with JDK1.8 on its own. Add a jitpack.yml file to the project file with this content:

jdk:
  - openjdk11

When I did that the problem went away.

like image 61
gokmenbayram Avatar answered Oct 09 '22 23:10

gokmenbayram


According to AGP release note here

When using Android Gradle plugin 7.0 to build your app, JDK 11 is now required to run Gradle. Android Studio Arctic Fox bundles JDK 11 and configures Gradle to use it by default, which means that most Android Studio users do not need to make any configuration changes to their projects.

JDK 11 is required if you using AGP 7.0.

You can modify AS JDK version like below (Only effect run app build project in AS small hammer or run action)enter image description here if Android Studio Arctic Fox | 2020.3.1 you use .

For some one building android app with AGP 7.0 with command line

  1. Modify JAVA_HOME value path to JDK 11 (Which will effect all of project on environment)
  2. Declare "org.gradle.java.home = path to JDK 11" in special project gradle.properties file (Effect to only this project)
like image 30
ending0421 Avatar answered Oct 10 '22 00:10

ending0421