Error: package javax.annotation does not exist after upgrade to lombok 1.16.2

JavaAndroidLombokIntellij Lombok-Plugin

Java Problem Overview


My android project builds fine with lombok 1.16.0, but once I change my dependency to target 1.16.2, I get the following error everywhere I'm using a lombok annotation:

Error:(20, 1) error: package javax.annotation does not exist

The Android SDK does not include all javax packages. What I'm wondering is if this is a bug in 1.16.2 or do I now have to add a dependency to javax.annotation?

Note: This is in Android Studio with Lombok plugin 0.8.8

Java Solutions


Solution 1 - Java

You can disable the generation of javax.annotation.Generated by putting the following line in a lombok.config file in one of the top directories of your project:

lombok.addGeneratedAnnotation = false

See the configuration documentation for more information.

Disclosure: I am a Lombok Developer.

Solution 2 - Java

If you're facing same issue in Android Studio using gradle - add following line to build.gradle:

provided 'org.glassfish:javax.annotation:10.0-b28'

Solution 3 - Java

The right answer for android development today is to use a version of dagger which is greater than 2.1 (because of the fix mentioned by @tomrozb is integrated in 2.1)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncopoliiView Question on Stackoverflow
Solution 1 - JavaRoel SpilkerView Answer on Stackoverflow
Solution 2 - JavaAlex PerevozchykovView Answer on Stackoverflow
Solution 3 - JavaSohamView Answer on Stackoverflow