I installed lombok from 'Preferences -> Plugin', but it's not working when I am trying to generate Getter & Setter. My code doesn't recognize it.
Is there anyone having idea how to setup lombok and use it to generate getter & setter annotation?
I installed lombok from 'Preferences -> Plugin', but it's not working when I am trying to generate Getter & Setter. My code doesn't recognize it.
Is there anyone having idea how to setup lombok and use it to generate getter & setter annotation?
You need not only to install Lombok Plugin
, but also add dependency to build.gradle
:
dependencies{
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12' //or v. 1.16.2 in your case.
}
More info on official guide.
Another answer with instructions.
There are so many posts on this subject its bewildering.
I am on the following:
And having torn most of my hair out, trying to figure out
what the heck is going on with gradle top level and project level,
THE ONLY COMBINATION that worked for me was this:
implementation 'org.projectlombok:lombok:1.18.0'
annotationProcessor 'org.projectlombok:lombok:1.18.0'
classpath 'org.projectlombok:lombok:1.18.0'
And here is the proof:
My god is it really this complicated to do something this simple.
There's a section related to this on official docs: https://projectlombok.org/setup/android
Follow the previous instructions (Gradle). In addition to setting up your gradle project correctly, you need to add the Lombok IntelliJ plugin to add lombok support to Android Studio:
Go to File > Settings > Plugins Click on Browse repositories... Search for Lombok Plugin Click on Install plugin Restart Android Studio Modify your application's dependencies block:
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.22'
annotationProcessor 'org.projectlombok:lombok:1.16.22'
}
Just in case be aware that if your project have mixed Kotlin and Java code - you can't use lombok normal way for now.
Based on this issue: https://github.com/projectlombok/lombok/issues/1169
EDIT:
from kotlin 1.7.20 with K2 compiler it is possible withot concerns.
https://kotlinlang.org/docs/whatsnew1720.html#support-for-kotlin-k2-compiler-plugins