Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok not working Android Studio 3.0

I want to use Lombok in one of my projects in android studio 3.0 and I have problems with it. Annotations work fine and they don't have any errors. Here are my Gradle dependencies which I added Lombok in it.

compileOnly "org.projectlombok:lombok:1.16.18"
annotationProcessor "org.projectlombok:lombok:1.16.18"

I have a problem with Annotation Processors too.
I have followed these steps:

  • in file>other settings>default settings i have enabled the Annotation Processors
  • I have Invalidate Caches / Restart
  • in the project settings suddenly the Annotation Processors settings appeared under the Build, Execution, Deployment>Compiler menu which it was not there before Invalidating Cache and I check its tick.
  • I have installed the Lombok plugin

when the Android Studio restarts the Annotation Processors setting is gone but the plugin doesn't show any errors.

After doing all this still it doesn't work.

import com.google.gson.annotations.SerializedName;

import lombok.Getter;

class UserModel {

    @SerializedName("uid")
    @Getter private String userId;


}

this is how I defined my model and cant get the getUserId out of it.

like image 797
Amir Ebrahimi Avatar asked Oct 29 '22 23:10

Amir Ebrahimi


1 Answers

Same issue for me. Android Studio 3.2 default config.

-Installed Lombok plugin -Added the following to app dependencies compileOnly 'org.projectlombok:lombok:1.18.4' annotationProcessor 'org.projectlombok:lombok:1.18.4'

And Lombok annotations were just ignored. After restarting Android Studio I got the Event log saying Lombok requires annotation processing, but Preferences/ Build Exec.../Compiler didn't show anything under it.

File / Invalidate caches restart did the trick. After that I could see the annotation processors option.

like image 157
juanlugm Avatar answered Nov 09 '22 12:11

juanlugm