Execution failed for task ':compileDebugJavaWithJavac'

Godot 4.2

issue :

What went wrong:
  Execution failed for task ':compileDebugJavaWithJavac'.
  > error: invalid source release: 17

image

What happened : I got this issue while trying to export my game project to file aab that i can upload to google play i dont know why it requires .abb instead of apk.

Question

I dont really know much about these so please help if you saw this error and solved it before thank you so much!

You just have to download and install Java jdk 17 : Java Archive Downloads - Java SE 17

It worked for me, make sure you download jdk17 and not jdk 17.x, I don’t know if it works but you can try :slight_smile:

It works for godot 4.0 but not for godot 4.2 ?
Where i can change java version for godot ?

It worked in 4.2 for me, I don’t know if you can change java version for godot, from what I understand, when you compile for android, godot does it for you in a way. If you want more control over the android build or to export in aab, you use gradle to compile by checking “use gradle build” in the export window and by installing an android template in the project tab. From there each export will no longer use godot compiler but gradle and to change java version of gradle it’s in the config.gradle file in YourProjectFolder/android/build.

But normally you don’t have to change that, just download and install the version of Java gradle tells you to.

Hope that helps !

Can u give me some steps to change config.grandle i would really happy if you solve that!

Just open the config.gradle file with notepad or any text editing software, for me in Godot 4.2.1 it look like that on the top of the file :

ext.versions = [
    androidGradlePlugin: '7.2.1',
    compileSdk         : 33,
    // Also update 'platform/android/export/export_plugin.cpp#OPENGL_MIN_SDK_VERSION'
    minSdk             : 21,
    // Also update 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
    targetSdk          : 33,
    buildTools         : '33.0.2',
    kotlinVersion      : '1.7.0',
    fragmentVersion    : '1.3.6',
    nexusPublishVersion: '1.1.0',
    javaVersion        : 17,
    // Also update 'platform/android/detect.py#get_ndk_version()' when this is updated.
    ndkVersion         : '23.2.8568313'

]

You just change the javaVersion number to the version you want, save the file and retry to export your game.

For the java version I don’t know what you have installed on your machine but I tried 17, 11 and 1.8 and it worked for me.

Where is even config.gradle?