本文介绍了使用Java 1.8 Gradle构建Android项目,即使Java Gradle工具链设置为JDK 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FAILURE: Build failed with an exception.
* Where:
Build file '/bitrise/src/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> 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检测本地安装的JVM Gradle选择与构建需求匹配的JRE/JDK(在本例中是支持Java 14的JVM) 如果没有找到匹配的JVM,它将自动从AdoptOpenJDK下载匹配的JDK
Android Gradle插件支持新的Gradle工具链吗? https://docs.gradle.org/current/userguide/toolchains.html
值得注意的库/插件/版本
- 运行AGP 7.0.0-alpha03
- Kotlin 1.4.21
- Android Studio北极狐金丝雀3
- jvmTarget 1.8
- Gradle Wapper 6.8-RC-1
应用程序模块Gradle配置如下(删除了一些详细信息)
android {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
kotlinOptions {
jvmTarget = Versions.jdkNumber
useIR = true
}
buildToolsVersion Config.buildToolsVersion
compileSdkVersion Config.compileSdk
buildFeatures {
compose true
dataBinding true
}
composeOptions {
kotlinCompilerVersion Versions.kotlin_version
kotlinCompilerExtensionVersion Versions.compose
}
androidExtensions {
experimental = true
}
}
推荐答案
刚刚解决了这个问题,在项目根文件夹中添加了jitpack.yml
文件,内容为:
jdk:
- openjdk11
- 帮助阅读:https://ayoubbenkhemis.medium.com/publish-android-library-with-jitpack-be00a29a8174
这篇关于使用Java 1.8 Gradle构建Android项目,即使Java Gradle工具链设置为JDK 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!