I created new project (from android studio wizard)...
# squarelibraries
c
I created new project (from android studio wizard). it defaults to using kotlin 2.0.20. i added okhttp latest as a dep and don't do anything with it, and then i get a somewhat obscure error message, but after bumping to kotlin 2.2.x. the error is resolved. still a noob on this topic. im assuming thats expected? that once any library I use moves to a newer version of kotlin that the consumer must also move to that version (bonus question... as a library author... is it in your best interest to just target 2.0.x instead?)
j
You should be using the latest version of the Kotlin compiler and Gradle plugin and setting your supported api/language version to the lowest-possible value for that compiler.
OkHttp and every other library we have will be doing this soon https://github.com/square/okhttp/issues/9032
👍 1
c
You should be using the latest version of the Kotlin compiler and Gradle plugin
cool
setting your supported api/language version to the lowest-possible value for that compiler.
Can you explain further/restate? is there some canonical list of java api/language version <> kotlin compiler somewhere?
j
it's not the java api/language version, it's the kotlin api/language version
This is a Gradle plugin, so it sets compatibility to 2.2 because the minimum-supported Gradle version is 9 which embeds Kotlin 2.2 per https://docs.gradle.org/current/userguide/compatibility.html#kotlin
It also targets Java 17 bytecode for that same reason
Back when we supported Gradle 8 the versions were different https://github.com/cashapp/licensee/blob/1.14.1/build.gradle#L67-L80
This sets the Kotlin metadata version, at least for the JVM. Other targets such as native do not support compiling for older versions and are tied solely to the Kotlin compiler version.
The Kotlin 2.3 compiler (in beta) removes the ability to target Kotlin 1.8, which is why we dropped support for Gradle 8
on a normal project this would have meant bumping to maybe 1.9 as the minimum, but since this is a Gradle plugin we get to make a big jump since there are no versions of Gradle that actually run Kotlin 1.9, 2.0, or 2.1.
c
a lot to take in but I think it makes sense! thanks for teaching!
j
Maybe i'll do a blog post once we start rolling it out. This is the second time this week I've written about it to someone.
🙏 2
e
Maybe a library for library authors would help with this? Call a single function in your build files to set the appropriate api/language for your given scenario.
j
That seems like a KGP feature request
It's already pretty easy, but it could be easier
I hate that toolchains are easier to configure than the Java bytecode. It means people use toolchains solely to target older bytecode which is not what they're useful for.
c
i did watch this a while back and it makes my head hurt (not the video, just all the versions, toolchains, etc) lol

https://www.youtube.com/watch?v=2Vp2QeBZkfo

j
oh this looks fun
yeah this talk is excellent