Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When I create a new Java class with one or more field and attach the @AllArgsConstructor annotation from lombok to it, then i get this message

Error:(9, 1) error: cannot find symbol class ConstructorProperties

from the on the Gradle Build console. I was able to reproduce this by creating a new empty Android project with this configuration.

The Class (never used or instantiated)

@lombok.AllArgsConstructor
public class Model {
    int foo;
    String bar;
}

build.gradle:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
provided 'org.projectlombok:lombok:1.14.8'
}

@Getter and @Setter from lombok do not cause any problems and even the @NoArgsConstructor is not mentioned by gradle, so is the AllArgsConstructor if there are no fields.

Is this a bug from Lombok or is this bug located in front of the screen?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
377 views
Welcome To Ask or Share your Answers For Others

1 Answer

Lombok generates the @ConstructorProperties by default for all generated constructors. On Android, that annotation is not available. As mentioned in the documentation it is possible to suppress the generation by either specifying suppressConstructorProperties=true for each @XxxArgsConstructor, or by using the following line in a high level lombok.config file:

lombok.anyConstructor.suppressConstructorProperties = true

Disclosure: I am a Lombok developer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...