kotshi icon indicating copy to clipboard operation
kotshi copied to clipboard

Generated annotation not found when compiling against Java 11

Open tompee26 opened this issue 4 years ago • 8 comments

When i updated my source/target compatibility to 11, javax.annotation.processing package is no longer there. Probably changed to javax.annotation only.

tompee26 avatar Oct 19 '21 07:10 tompee26

javax.annotation.processing.Generated is available since Java 9.

Which JDK are you using to compile your project and are you setting both the Java and Kotlin target version or only one of them?

ansman avatar Oct 19 '21 16:10 ansman

I am using JDK 11. I am setting both java and kotlin.

tompee26 avatar Oct 19 '21 23:10 tompee26

Is this Android or just JVM?

ansman avatar Oct 19 '21 23:10 ansman

This is on Android

tompee26 avatar Oct 20 '21 01:10 tompee26

Found this somewhere. Might be related: https://github.com/google/dagger/issues/1339

tompee26 avatar Oct 20 '21 01:10 tompee26

Can you post the full build error?

ansman avatar Oct 20 '21 19:10 ansman

I set this sample project up. Both with and without the javax.annotation dependency, there are compile errors. https://github.com/tompee26/KotshiJava11Test

tompee26 avatar Oct 21 '21 01:10 tompee26

Sorry for the slow response, I'm still investigating. My preliminary findings are that the Android Gradle Plugin does something which makes it work for generated Java code but it does not work for the Kotlin code.

For now, to become unblocked, you can include the javax.annotation-api dependency. Another option is to add an option in Kotshi to disable the generation.

I will file an issue against the Android Gradle Plugin once I can confirm it is at fault.

ansman avatar Nov 02 '21 17:11 ansman

@tompee26 Do you still see this issue?

ansman avatar Sep 09 '22 17:09 ansman

So I've found the root cause of the issue which is that Android does not support Java 11 yet and you won't be able to target Java 11 when compiling. If you change to Java 8 then it'll work as expected.

ansman avatar Sep 19 '22 14:09 ansman