Kapt annotation processing - how to show full stacktrace
Asked Answered
S

2

22

I am working on a android project using Kotlin, Databinding and Room. Sometimes the build fails with a error message, containing no information about what exactly went wrong, except that it has something to do with the annotation processor (which can have many causes...).

shortened Example:

org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains

[more stack trace lines]

Caused by: org.jetbrains.kotlin.kapt3.base.util.KaptBaseError: Error while annotation processing

[even more stack trace lines]

at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
... 32 more

Finding the cause, then means time consuming backtracking of my steps (and maybe using git stash) and guessing, when one the 32 hidden lines at the end seems likely to contain some useful information about what actually went wrong.

So the question is: how to show the full stack trace?

I tried setting the -Xmaxerrs 500 in my build.gradle as shown here https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options as well as various variants of this, I found on SE (sorry, don't remember which exactly). None made any difference. Maybe i put the block in the wrong part? (tried module level, android -> defaultConfig -> kapt)

Simulacrum answered 20/2, 2020 at 16:0 Comment(1)
#60324517Jaret
H
24

Add kapt.verbose=true to your project's gradle.properties file.

Hodess answered 23/2, 2020 at 1:5 Comment(5)
unfortunately this does not change anything :(Simulacrum
I did see more output after doing this.Herrod
It works for me. And I find dagger compile error after enable itMercorr
This worked for me after hours of scratching my head. Found a silly issue in the output.Carmichael
It worked for me as well. With the verbose log I was able to identify the problem. Thanks.Jamnis
C
2

In my case, the issue was apparently with the 'suspend' keyword added to my Dao function. I may be missing dependency or there may be some dependency issue.

For example I changed the following:

    @Query("select * from election_table")
**suspend** fun getAllElections():LiveData<List<Election>>

to

    @Query("select * from election_table")
fun getAllElections():LiveData<List<Election>>

Room version: = "2.2.5"

Update: Yep - the issue is ensure you have the following dependencies:

 //Room
implementation "androidx.room:room-runtime:$version_room"
kapt "androidx.room:room-compiler:$version_room"
implementation "androidx.room:room-ktx:$version_room"

I was missing the last one. Added suspend keyword again, and now compiles like a charm!

Choong answered 24/6, 2022 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.