1

My Nativescript 6 Android build suddenly is failing - I didn't update any modules except for the NS CLI 8.2.3 - but the tns-android is 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

Again this was working before the CLI update.

I'm using Java 1.8 - seems to be a big jump to Java 11.

dashman
  • 2,858
  • 3
  • 29
  • 51

1 Answers1

0

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

As it can be read from the error message, gradle is expecting jdk 11 and you have jdk 8 configured. Install jdk 11 on the system and set JAVA_HOME environment variable to point to it.

This is probably happening because nativescript 8.2.3 seems to be using gradle 7 and it expects jdk 11. You can specify gradle version in a somewhat hacky way likewise: How can I downgrade the Gradle in NativeScript?

leogps
  • 894
  • 7
  • 6
  • Thanks - I didn't know JDK 1.8 was referred to also as JDK 8. It seemed like a big jump from 1.8 to 11. NS has been useful tool for me - but the rate at which they make major changes that break the build or app is so frustrating. Seriously what's in gradle 7 that the previous wasn't doing - it was building and publishing an Android app fine. – dashman Apr 03 '22 at 20:03
  • I agree with you. Nativescript team is aggressive in pushing breaking changes. However, in this case, i believe, in order to support Android 12, they had no choice but upgrade gradle which in turn required them to upgrade java version. Also, after jdk 8, next LTS version is jdk 11. Jdk9 and jdk10 are not LTS versions. – leogps Apr 06 '22 at 00:55