Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gregko opened this issue Oct 6, 2021 · 7 comments

Comments

@gregko
Copy link

gregko commented Oct 6, 2021

FAILURE: Build failed with an exception.

  • Where:
    Build file '/home/jitpack/build/app/build.gradle' line: 2

  • What went wrong:
    An exception occurred applying plugin request [id: 'com.android.application']

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.

Please provide:

Thank you!

@loper7
Copy link

loper7 commented Oct 8, 2021

+1

@Vipinbalakrishnan
Copy link

Vipinbalakrishnan commented Oct 9, 2021

@gregko Please do the below 2 steps.

First, change JAVA8 from your build.gradle(app module) file to 11 like below

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

Secondly, add a file in the root folder of your project-
-named jitpack.yml file with the following content.

jdk:

  • openjdk11

Please read above line as below.
space hyphen space openjdk11 (Cannot escape hyphen here. it becomes a bullet point )

These two steps will solve the problem that you are facing.

This happens because of the gradle build tools version.
Latest versions requires Java 11.

@gregko
Copy link
Author

gregko commented Oct 9, 2021 via email

@Vipinbalakrishnan
Copy link

Vipinbalakrishnan commented Oct 20, 2021

@gregko

For the error that mentioned as configure project, use the latest
-gradle plugin version in root buil.gradle file in the dependencies section as below.

dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
}

Please check the below steps that are necessary to publish a library to jitpack.io

Omit the ones related to java 11 as you have already did those.

  1. Added jitpack.io to build.gradle file of the root of the project as below.



maven { url "https://jitpack.io" }


2. Added plugin maven-publish in the build.gradle file of the module as below along with library plugin.

plugins {
id 'com.android.library'
id 'maven-publish'
}

3.Added jitpack.yml in the root of the project for JAVA 11 support

As below



jdk:

  • openjdk11

4.Change java version to 11 in build.gradle file of the app module and library module inside android {} as below

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

5.Add maven publication settings as below in the build.gradle of module



afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
from components.release
groupId = 'com.github.yourgitid'
artifactId = 'your-repository'
version = 'x.x'
}
}
}
}

@gregko
Copy link
Author

gregko commented Oct 20, 2021 via email

@Vipinbalakrishnan
Copy link

@gregko,

Glad that it helped you.

Please close the issue if it is worked.

Thank you.

@gregko gregko closed this as completed Oct 21, 2021
alkathirikhalid pushed a commit to alkathirikhalid/connection that referenced this issue Nov 20, 2021
@alkathirikhalid
Copy link

Useful,

I had the same problem the solution provided resolved it:

  • Could not generate a decorated class for type AndroidMavenPlugin.

Code Changes

Build / Logs

Thank you.

ss26dev pushed a commit to ss26dev/GoogleBillingApi that referenced this issue Nov 28, 2021
ss26dev pushed a commit to ss26dev/GoogleBillingApi that referenced this issue Nov 28, 2021
ss26dev pushed a commit to ss26dev/GoogleBillingApi that referenced this issue Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants