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?
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