Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

I recently encountered some of these problems while publishing components using JitPack, which TOOK me a while to resolve. 🙃

Problem 1 – Adjust the JDK version to 11

  • 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.

This problem, if we are native Android Studio, is very simple, directly change gradle, but jit on 😶, the solution is as follows:

Create a jitpack.yml file as follows:

jitpack.yml

jdk:
  - openjdk11
Copy the code

Problem 2 – Unable to create AndroidMavenPlugin

  • What went wrong:

A problem occurred evaluating script.

Failed to apply plugin ‘com.github.dcendents.android-maven’. Could not create plugin of type ‘AndroidMavenPlugin’. > Could not generate a decorated class for type AndroidMavenPlugin. > org/gradle/api/publication/maven/internal/MavenPomMetaInfoProvider

Solutions:

Open the build.gradle for the corresponding component (if your components are already written in your app, just write them to your app) and add the following:

plugins {
   	...
    id 'maven-publish'
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = 'com.petterp'
                artifactId = 'statex'
                version = '1.0-dev02'}}}}Copy the code
  • groupIdIs the full name of your package except labrary
  • artifactIdThe correspondinglabrary id, the component ID
  • versionThe version number

The sample

For example, the full name above is com.petterp.statex, and statex is my component library, so it is written this way.

Of course, you can also configure the unified management of version into a special Gradle file, which can be directly referenced here.