8

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.

M3-n50
  • 803
  • 1
  • 13
  • 23
  • Are you using annotationProcessor Dependency in gradle?? – Aman Rawat Feb 21 '22 at 16:34
  • https://stackoverflow.com/questions/62131564/a-failure-occurred-while-executing-org-jetbrains-kotlin-gradle-internal-kaptexec You may find this helpful. – Aman Rawat Feb 21 '22 at 16:36
  • This has helped me get rid of the 1.8 error in --scan. Now I get this result: https://scans.gradle.com/s/aa5y7o2dtps62 – M3-n50 Feb 22 '22 at 08:05
  • Kind of same issue with v2.5.0-alpha02 of Room, kotlin v1.6.21, and jetpack compose 1.2.0-beta03 – Akhha8 Jun 09 '22 at 06:26

2 Answers2

0

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

Vik
  • 1
  • 1
  • Have you also upgraded your Kotlin to 1.7.0? If I keep it up to date with the latest compatible with Compose I still get the same error. If I go above and ignore it I get a userIR error (which is caused by incompatibility if I understand it correctly) – M3-n50 Jun 28 '22 at 10:34
  • Yes, upgraded to Kotlin 1.7.0, however my project is not using Compose – Vik Jun 30 '22 at 21:07
  • Unfortunately this solution didn't work for me. I had to downgrade from Kotlin 1.7 to Kotlin 1.6.21 to make my sources compile. – Alexander Poleschuk Jul 06 '22 at 10:11
0

So I've had to work on this project again after a year.

I've discovered that the [MissingType] errors were only occurring in entities that had SerializedName annotations. My project is set up with multiple modules and com.google.code.gson:gson was not imported into the module containing the database entity.

After finally adding it to that build.grade the project would compile again.

M3-n50
  • 803
  • 1
  • 13
  • 23