android - Visual Studio Code App Center : Android Gradle plugin requires Java 11 to run. 您当前使用的是 Java 1.8

标签 android visual-studio-app-center

我使用 Visual Studio Code App Center 构建我的 android 应用程序,之后一切正常,但现在构建失败,出现以下异常。我该如何解决这个问题?

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/runner/work/1/s/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`.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 45s
Error: /Users/runner/work/1/s/gradlew failed with return code: 1
    at ChildProcess.<anonymous> (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/1.128.0/node_modules/vsts-task-lib/toolrunner.js:569:30)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:920:16)
    at Socket.<anonymous> (internal/child_process.js:351:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:509:12)
##[error]Error: /Users/runner/work/1/s/gradlew failed with return code: 1

最佳答案

如果您使用 Visual Studio Code App Center ,当您在 android 项目中使用 JAVA 11 时,您可能会遇到同样的问题。如果您正在寻找 MS App Center 问题的解决方案,这可能会对您有所帮助!

  • 转至 https://appcenter.ms/users/user1/apps/yourapp/build/branches
  • 点击设置图标进入Build configuration
  • 向下滚动到 Environment并打开。
  • 设置 JAVA_HOME$(JAVA_HOME_11_X64)

  • enter image description here

    关于android - Visual Studio Code App Center : Android Gradle plugin requires Java 11 to run. 您当前使用的是 Java 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71876101/

    相关文章:

    javascript - 为什么我的 SectionList 有时只呈现一个部分?

    react-native - 部署 key 为空 appcenter 代码推送 cli

    c# - 如何在 App Center 的 Xamarin.Forms 中使用设置环境变量

    azure-devops - 从哪里获取 Azure Pipeline AppCenterDistribute@3 Task destinationStoreId?

    java - 方法无效

    android - 检测外部应用程序何时在 Android 中运行 onCreate、onStart、onResume

    android - 通过通知将数据返回到其他 Activity

    android - 如何在android studio中更改微调器及其箭头的颜色

    c# - Xamarin AppCenter Crashes.TrackError 没有显示我在 AppCenter 中期望的详细信息

    ios - CocoaPods 在 Microsoft AppCenter for React Native 项目上安装失败