Cannot compile since updating kotlin to 1.6.10 & room 2.4.1

Viewed 1348

I'm getting an error since I upgraded to Kotlin 1.6.10 and room to 2.4.0. The error is unclear tho, so I don't really know where to start looking.

Execution failed for task ':app:kaptDebugKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction java.lang.reflect.InvocationTargetException (no error message)

Try: Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.

I'm guessing there's something incompatible in my entities, but when downgrading everything works flawlessly. My question is: how can I detect what is wrong? For me the errors are quite vague.

When I run gradlew --scan it says my JVM is still 1.8, but I've updated everywhere to 11.

EDIT: I've managed to force my Gradle using 11 by changing the org.gradle.java.home property. Now it's giving me the following error:

 A failure occurred while executing
 org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
  (No message provided)
    (No message provided)
      java.lang.IllegalArgumentException: <nulltype> cannot be represented as a Class<?>.
       <nulltype> cannot be represented as a Class<?>.

EDIT2:

I've read in another StackOverflow thread that I should update AS to the latest patch which I did. Unfortunately, this didn't help.

EDIT3:

It seems like the room version (2.4.1) is also part of the problem. When downgrading everything but room it is still an error. If I try to run with kotlin 1.5.31, room 2.3.0 & compose 1.0.5 it runs fine.

EDIT4:

After upgrading to room 2.4.2 and also adding KSP I get the following error instead:

[ksp] [MissingType]: Element 'be.tradecom.kraken.objects.parts.Part' references a type that is not present - be.tradecom.kraken.objects.parts.Part

When searching for this error I only get 1 result of someone who had the same problem and fixed it by upgrading to Kotlin 1.6.0. I tried downgrading from 1.6.10 to 1.6.0, but compose 1.1.0 needs 1.6.10.

I removed big parts of the first error because I reached the character limit and I don't think it matters anymore.

1 Answers

I fixed this error by the following steps:

1- ensure that Gradle JDK is set to "Embedded JDK version 11.0.12/snap/android-studio/121/android-studio/jre"

2- Invalidate Caches - check both options are ticked, including "Clear filsystem cache and local history" then "Invalidate and Restart"

3- In AD menu go to File -> Project Structure -> on left hand menu select "Suggestions" and upgrade all components listed there.

4- changed compileSdk 31 to compileSdk 32

I also found this post helpfull: https://stackoverflow.com/a/62919508/17650331

Related