Nativescript Android 构建突然失败 (NS6)

Nativescript Android build fails suddenly (NS6)

我的 Nativescript 6 Android 构建突然失败 - 除了 NS CLI 8.2.3 我没有更新任何模块 - 但 tns-android 是 6.5.x

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/mini/Projects/app-mobile/platforms/tempPlugin/nativescript_webview_ext/build.gradle' line: 6

* What went wrong:
A problem occurred evaluating root project 'nativescript_webview_ext'.
> Failed to apply plugin 'com.android.internal.library'.
   > 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 684ms
Failed to build plugin @nota/nativescript-webview-ext : 
Error: Command ./gradlew failed with exit code 1

同样,这在 CLI 更新之前有效。

我正在使用 Java 1.8 - 似乎是 Java 11 的一个大跃进。

Failed to apply plugin 'com.android.internal.library'.

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 需要 jdk 11 而您已经配置了 jdk 8。在系统上安装 jdk 11 并设置 JAVA_HOME 环境变量指向它。

这可能是因为 nativescript 8.2.3 似乎正在使用 gradle 7 并且它期望 jdk 11。您也可以用一种有点 hacky 的方式指定 gradle 版本: How can I downgrade the Gradle in NativeScript?