gpt4 book ai didi

java - Azure构建错误: "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"

转载 作者:行者123 更新时间:2023-12-02 05:50:56 24 4
gpt4 key购买 nike

azure devOps 中构建 Flutter 应用程序时,我收到此错误:

Build file 'D:\a\1\s\android\app\build.gradle' line: 24

* 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`.

我已经尝试过,这些解决方案:

  • 使用 - openjdk11 值创建 jitpack.yml 文件。
  • 将以下行添加到 android {} block 内的 app/build.gradle 文件中:

...

compileOptions {

sourceCompatibility JavaVersion.VERSION_11

targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}

还有其他解决方案,但我的错误没有解决。顺便说一句,我可以轻松地在 Mac 上本地运行应用程序并构建 apk,没有任何错误,但是当我推送代码时,Azure 会给出这些构建错误。

最佳答案

通过将以下行添加到 azure-pipelines.yml 文件中解决了我的错误:

steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

关于java - Azure构建错误: "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72140664/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com