1
votes

This is my setup:

  • AndroidStudio Lombok Plugin is installed
  • Enable Annotation Processing is checked in AndroidStudio Settings
  • Gradle wrapper is using version 4.6
  • I am using kotlin version 1.2.71
  • I am using com.android.tools.build:gradle:3.2.1
  • I tried "Invalidate cache / Restart AndroidStudio" after each change
  • Lombok dependencies are defined like this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

dependencies {
    compileOnly "org.projectlombok:lombok:1.18.2"
    kapt "org.projectlombok:lombok:1.18.2"
}

When I build the app, I get the followin error:

Annotation processors must be explicitly declared now. 
The following dependencies on the compile classpath are found to 
contain annotation processor.  
Please add them to the annotationProcessor configuration.
    - lombok-1.18.2.jar (org.projectlombok:lombok:1.18.2)

I also tried this dependency setup:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

dependencies {
    compileOnly "org.projectlombok:lombok:1.18.2"
    annotationProcessor "org.projectlombok:lombok:1.18.2"
}

But then I get "cannot find symbol"-errors all over the place, because no getters/setters are generated by lombok.

1

1 Answers

0
votes

Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor.

Please add them to the annotationProcessor configuration. - lombok-1.18.2.jar (org.projectlombok:lombok:1.18.2)

Try adding it as annotationProcessor:

annotationProcessor 'org.projectlombok:lombok:1.18.2'

However, read this: Is it possible to use Lombok with Kotlin?

Lombok does not run on your source code, but on the AST. Anyway, it is an annotation processor that is run at compile-time by the Java compiler. The Kotlin compiler does not use these annotation processors. See also the answer https://stackoverflow.com/a/35530223/2621917 straight from the horse’s mouth.