Home > Enterprise >  how to change gradle version in nativescript
how to change gradle version in nativescript

Time:05-13

I'm confused as how to change a specific configuration somewhere to determine the version of my gradle, in a nativescript project. My workspace is created with nx and when I try to run the app with npx nx run test:android I get this error message:

Could not compile settings file '<somepath>\start\learn\apps\nativescript-test\platforms\android\settings.gradle'.
> startup failed:
  General error during conversion: Unsupported class file major version 62

Based on my research if I need to resolve this issue I need to either update my gradle version or downgrade my JDK version. The solution I'm searching for is to how to specify my gradle version. Thanks in advance.

CodePudding user response:

based on my understanding version of gradle is defined by @nativescript/android package (read its README.md), so if updating the @nativescript/android doesn't help do the next steps

1- install jdk 18 -> because its the first version that supports major version 62
2- add JAVA_HOME to env vars
3- in platform/gradle.properties add org.gradle.java.home=C:\\Program Files\\Java\\jdk-18.0.1  (because in my case gradle didn't read form JAVA_HOME)
4- change platform/gradle-wrapper gradle version to 7.4.2
5- in platform/build.gradle do this: replace whatever version of plugin to classpath 'com.android.tools.build:gradle:7.2.0'
  • Related