Hello, I'm new to this slack channel and looking f...
# community-support
c
Hello, I'm new to this slack channel and looking for help in getting things configured I am trying to use an ionic capacitor app and running into issues with JDK versions in gradle. Gradle seems to be convinced that I need JDK 21 and its not there (even though I have JDK 21 installed) but I believe my project needs JDK17. VS Code has never been able to launch the android app. I've had to build, sync, and then go to Android studio to open it. No matter what I do, I can't get android/app/capacitor.build.gradle to show any version other than 21
* What went wrong:
Execution failed for task ':capacitor-android:compileReleaseJavaWithJavac'.
> error: invalid source release: 21
Not sure If I'm posting in the right place or asking the right question, but if anyone could assist it would be greatly appreciated!
c
The best way to go about this is to use toolchains, that way whatever jdk your ide/tool wants to invoke gradle with is independent of the version used to compile/test your app.
👆 1
v
What Clayton said. Besides that, the error is telling you, that you either configured a Java <21 toolchain or have no toolchain configured but run Gradle with Java <21, but in your build script use
sourceCompatibility = 21
which generally is a bad idea anyway.
c
got it. Thanks! I'll try to explore using toolchains
Does anyone know where android/app/capacitor.build.gradle gets the compile options from? I tried doing toolchains, I've been throwing errors at google and chatgpt, and no matter what I do it keeps going back to android { compileOptions { sourceCompatibility JavaVersion.VERSION_21 targetCompatibility JavaVersion.VERSION_21 } }
v
What do you mean by "gets them from"? Do you mean you edit the file and it reverted? If so, that's not really a Gradle question, as Gradle does not edit build scripts, you need to find out who writes this file. If that is a legacy script plugin (something you use with "apply from", you should anyway replace it or report a but to whoever forces you to use it, they have many quirks and are discouraged. If that is one of those bad legacy script options, you can probably just declare the toolchain in the build script where you apply it.