Trying to set up unit testing in my multiplatform ...
# multiplatform
j
Trying to set up unit testing in my multiplatform project. However, I’m getting this error:
'compileDebugUnitTestJavaWithJavac' task (current target is 1.8) and 'kspDebugUnitTestKotlinAndroid' task (current target is 17) jvm target compatibility should be set to the same Java version.
How can I fix this?
Screenshot 2023-06-27 at 4.46.00 PM.png,Screenshot 2023-06-27 at 4.46.14 PM.png
l
What AGP are you using? I think 8.0 has this bug.
j
8.0.2
l
I'm on mobile right now, but the AGP 8.0 docs have a big red rectangle noting this bug and linking to how to fix it. If using giraffe instead is fine, you could update to 8.1, which has the fix.
j
Hmm, I can’t seem to find that explanation. If you remember when you get to a keyboard, it would be great if you could send me a link.
@Landry Norris I updated to Giraffe, updated AGO to 8.1.0-rc01, and it still is giving this issue.
l
I can't seem to find the warning in the docs anymore. The workaround it originally linked to looked like the following:
Copy code
android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
}
Of course, if you already have an android block, add the compile options inside of it.
It's odd that updating to 8.1.0-rc didn't fix it. They'd said it was fixed in 8.1.0-alpha09 or something like that. I'm going to have to look again to see if I can find it so I can convince myself I'm not going crazy.
I believe it was related to this: https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support Android uses java 17 now, but the target wasn't getting set to 17 due to this bug. The code they suggest fixed it when I ran into this issue.
j
Thanks for the info! I appreciate it!!