https://kotlinlang.org logo
#compose
Title
# compose
m

Marcelo Hernandez

04/12/2023, 6:15 PM
Trying to update to Compose Compiler 1.4.5 and I'm seeing the following error. Anyone else run into this? I'm using JDK 11.
👀 1
i

itnoles

04/12/2023, 6:20 PM
that's Java 17
m

Marcelo Hernandez

04/12/2023, 6:30 PM
That's what I figured. But no where in the release notes am I seeing a mention of this "breaking" change: https://developer.android.com/jetpack/androidx/releases/compose-compiler#version_145_3
k

Kirill Grouchnikov

04/12/2023, 6:42 PM
Are you building from command line or from Studio?
m

Marcelo Hernandez

04/12/2023, 6:43 PM
Command line.
I guess I'm wondering if potentially making JDK 17 required was intended for Compose Compiler 1.4.5. 🤔
I'm seeing the same issue in CI (GitHub Action) which has always been configured to use Java 11 for our build jobs.
b

Ben Trengrove [G]

04/12/2023, 9:44 PM
The forced upgrade to Java 17 is being rolled back in another release
m

Marcelo Hernandez

04/12/2023, 9:52 PM
The release notes have also been updated to include this information about the JDK 17 requirement for 1.4.5.
c

Colton Idle

04/13/2023, 12:49 PM
there was a force update for compose + jdk?
m

Marcelo Hernandez

04/13/2023, 1:19 PM
Yes, but next week there will be a 1.4.6 release that reverts back to JDK 11.
f

Francis Mariano

04/19/2023, 4:08 PM
Do you think 1.4.6 release is available this week or the next??
m

Marcelo Hernandez

04/19/2023, 4:11 PM
I believe it is supposed to come out this week. But for what it's worth, Android Gradle Plugin 8 also shipped last week and it too requires JDK 17. So if you're interested in updating to Android Gradle Plugin 8, Gradle
8.x
, and Kotlin 1.8.20, you'll have to update to JDK 17 regardless.
From there, Compose Compiler
1.4.5
can be used as is without having to wait for
1.4.6
😄
f

Francis Mariano

04/19/2023, 4:16 PM
Ok, I want to update a library to kotlin 1.8.20 // compose-multiplatform 1.4.0 // compose-compiler 1.4.5/1.4.6 but I do not want to force the JDK 17
m

Marcelo Hernandez

04/19/2023, 4:17 PM
If I'm not mistaken, I believe I saw a warning from the Kotlin Multiplatform plugin with Kotlin 1.8.20 that Gradle 7.x is not officially supported. 🤷‍♂️
It's inevitable if you want to keep up with the latest and greatest tooling to ultimately update to JDK 17.
You'd still target Java 11 with JDK 17.
If I'm not mistaken, I believe I saw a warning from the Kotlin Multiplatform plugin with Kotlin 1.8.20 that Gradle 7.x is not officially supported. 🤷‍♂️
I could be wrong though. 🙂
f

Francis Mariano

04/19/2023, 4:24 PM
You'd still target Java 11 with JDK 17.
Like this???
Copy code
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}
m

Marcelo Hernandez

04/19/2023, 4:26 PM
For Android library modules, yes.
If you have pure JVM modules, you'll need to do
Copy code
tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions {
        jvmTarget = "11"
    }
}

// If you still have code in Java.
// This includes if you use Dagger/Hilt with pure Kotlin since Dagger/Hilt code-gen is in Java.
tasks.withType<JavaCompile>().configureEach {
    sourceCompatibility = "11"
    targetCompatibility = "11"
}
Assuming Kotlin Gradle DSL ☝️
f

Francis Mariano

04/19/2023, 5:06 PM
So if I publish a library with JDK 17, a consumer can build it with JDK 11 ???
m

Marcelo Hernandez

04/19/2023, 5:10 PM
I believe as long as the source and target compatibility are properly configured to 11, yes. Does your library have a sample app that you can test this with?
j

jim

04/19/2023, 5:54 PM
Compose Compiler 1.4.6 with support for Java11 toolchain is released: https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.4.6
60 Views