App Center 無法成功建置 Java 11 的 Android 專案

CI/CD

這幾天在升級尋車小幫手的專案設定,結果升完導致我在 App Center 的 CI/CD 跑不過,這感覺還滿正常的,畢竟升版本對 CI/CD 絕對是一件大事,不過我的專案把 Java 1.8 換 Java 11 了,怎麼 App Center 還是吃到 1.8 的設定?

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

再巡一次專案設定,確定都置換完畢了,因此猜測癥結點可能在 App Center。果不其然,也有人回報一樣的問題:

Android Gradle plugin 7.0.0+ requires Java 11 to build app · Issue #2067 · microsoft/appcenter
Describe the solution you'd like To support appcenter build with the latest gradle plugin, could you please add Java 11?...

解決方法是將 JAVA_HOME 的環境變數設定為 $(JAVA_HOME_11_X64),看來 App Center 的 JAVA_HOME 預設寫死 1.8,也沒去檢查我的 compileOption 設定的 Java 版本才會造成這個問題。

留言列表

Copied title and URL