当前位置: 首页 > 知识库问答 >
问题:

发布jitpack库时“Android Gradle插件需要Java 11才能运行”

邓翼
2023-03-14

我试图通过使用这个github repo发布一个空的jitpack库来进行测试

* 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`.
emre@Emres-MacBook-Pro / % java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment OpenLogic-OpenJDK (build 11.0.8+10-adhoc.admin.jdk11u)
OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 11.0.8+10-adhoc.admin.jdk11u, mixed mode)
emre@Emres-MacBook-Pro / % 
org.gradle.java.home=/Library/Java/JavaVirtualMachines/openlogic-openjdk-11.jdk/Contents/Home
* What went wrong:
Value '/Library/Java/JavaVirtualMachines/openlogic-openjdk-11.jdk/Contents/Home' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)
compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
    jvmTarget = '11'
}

Android Gradle插件需要Java11才能运行。您目前使用的是Java1.8

项目工作在我的本地,我有那些错误在jitpack网站上一次当我推我的标签

共有1个答案

裴心思
2023-03-14

通过使用jitpack.yml(将其添加到项目根目录中)解决了这个问题,结果显示jitpack使用1.8作为默认值,并且不关心在gradle上设置了什么。

# configuration file for building snapshots and releases with jitpack.io
jdk:
  - openjdk11
before_install:
  - ./scripts/prepareJitpackEnvironment.sh

详细信息https://jitpack.io/docs/building/#java-version

 类似资料: