yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.46k stars 1.57k forks source link

Java 21 and Gradle #12319

Open SeventhM opened 4 days ago

SeventhM commented 4 days ago

Before creating

Problem Description

Currently, on some machines, if you do nothing except download Studio and download the code, you cannot build the code. You will instead get the following:

 Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2. Cannot sync the project.

We recommend upgrading to Gradle version 8.9.

The minimum compatible Gradle version is 8.5.

The maximum compatible Gradle JVM version is 19.

Possible solutions:
 - Upgrade to Gradle 8.9 and re-sync
 - Upgrade to Gradle 8.5 and re-sync

There's also the stack trace I can paste in, but I double much of it is useful since we probably should update gradle anyways

``` org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':buildSrc:compileKotlin'. Caused by: org.gradle.api.internal.tasks.properties.PropertyEvaluationException: Error while evaluating property 'compilerOptions.jvmTarget' of task ':buildSrc:compileKotlin'. Caused by: org.gradle.api.internal.provider.AbstractProperty$PropertyQueryException: Failed to calculate the value of property 'jvmTarget'. Caused by: java.lang.IllegalArgumentException: Unknown Kotlin JVM target: 21 at org.jetbrains.kotlin.gradle.dsl.JvmTarget$Companion.fromTarget(JvmTarget.kt:26) at org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain$wireJvmTargetToToolchain$1$1.invoke(DefaultKotlinJavaToolchain.kt:78) at org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain$wireJvmTargetToToolchain$1$1.invoke(DefaultKotlinJavaToolchain.kt:70) ... ```
SeventhM commented 4 days ago

Interestingly, on this machine specifically, I'm also getting

org.gradle.jvm.toolchain.internal.NoToolchainAvailableException: Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=17, vendor=any vendor, implementation=vendor-specific} for WINDOWS on x86_64

Considering it's a brand new laptop, wouldn't be surprised if has something to do with windows 11 not actually shipping with java installed and Studio using only Java 21 as a backup

itanasi commented 4 days ago

Personally going to just pull an archived version. I think Jellyfish used to work https://developer.android.com/studio/archive

itanasi commented 4 days ago

Seems Hedgehog, 2023.1.1 Patch 2, works. Supports the default AGP 8.2.2. Doesn't yell that Gradle is out of date and depreciated. Had to flush the SDKs and JDK manually and reinstall.

yairm210 commented 3 days ago

Updated in #12325