I have a java project that builds fine in Android Studio and on the CI server.
Building a release version with gradle on the terminal fails though. I get the following output:
Database_Impl.java:42: error: package javax.annotation does not exist
Database_Impl.java:44: error: cannot find symbol
@Generated("androidx.room.RoomProcessor")
Some similar issues with Dagger suggests that this is a problem with the Java version of the build system.
I'm using a Mac and my javac version is: 10.0.2
I had the same issue and adding implementation "javax.annotation:jsr250-api:1.0"
to build.gradle dependencies helped.
This seems to be related to the Java version that is active on your machine.
There is a similar bug ticket with Dagger: https://github.com/google/dagger/issues/1449
The result of the discussion is that this is a bug in KAPT: https://youtrack.jetbrains.com/issue/KT-32804
The workaround is to put
if (project.hasProperty('kapt')) {
// Reference for 'kapt' DSL: https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options
kapt {
// we expect this closure to run over a org.jetbrains.kotlin.gradle.plugin.KaptExtension
javacOptions {
option("-source", "8")
option("-target", "8")
}
}
}
at the end of the build file of the affected module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With