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

FAILURE: Build failed with an exception. #4777

Closed
astrit-veliu opened this issue Oct 10, 2021 · 6 comments
Closed

FAILURE: Build failed with an exception. #4777

astrit-veliu opened this issue Oct 10, 2021 · 6 comments
Labels

Comments

@astrit-veliu
Copy link

Please provide:

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.

@Vipinbalakrishnan
Copy link

@astrit-veliu

You need to specify the jitpack repository to use java 11. Or else it will default to 1.8.

Most recent gradle plugins need Java 11.

So do the following.

Added jitpack.yml in the root of the project for JAVA 11 support.
Create a file with name as 'jitpack.yml' with the following content.

jdk:
-openjdk11

@Vipinbalakrishnan
Copy link

@astrit-veliu

Also if you are getting artifacts not found error please checkout the below complete step to publish the library.

I am able to successfully release my library to jitpack.io by the following steps.

1.Update gradle plugin version to the latest in build.gradle file
-of the project root in the dependencies section as below.

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

2.Add jitpack.io repository to build.gradle file of the root as well as the library module of the project as below.


repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}


3.Add 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'
}

4.Add jitpack.yml in the root of the project for JAVA 11 support.
Create a file with name as 'jitpack.yml' with the following content

jdk:

  • openjdk11

(read as, space hyphen space opejdk11 or copy the whole text)

5.Change java version to 11 in build.gradle file of the app module and library module inside android {} as below
New gradle plugin builds on java 11.

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

6.Added 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.Vipinbalakrishnan'
artifactId = 'ribbonlayout'
version = '1.1'
}
}
}
}

Note:-
Sixth step is necessary.

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Nov 10, 2021

Can you please make it auto-use the JDK 11 based on what's in the gradle file? Or even make the new default?
New projects nowadays on Android use JDK 11 by default...
In the past it was easy to use Jitpack, as there was nothing needed to be added. Why now it changed?

@astrit-veliu
Copy link
Author

@Vipinbalakrishnan, @AndroidDeveloperLB thank you for your suggestion, will try them and see if it fixes the issue :)

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Mar 26, 2022
@github-actions
Copy link

github-actions bot commented Apr 9, 2022

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@AndroidDeveloperLB @Vipinbalakrishnan @astrit-veliu and others