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)

Mickverm
  • 86
  • 7
tarbos
  • 241
  • 1
  • 2
  • 6

2 Answers2

22

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

es0329
  • 1,366
  • 1
  • 18
  • 35
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!

awaqar
  • 149
  • 1
  • 6