[英]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. 我想在android studio 3.0中的一个项目中使用Lombok,我遇到了问题。 Annotations work fine and they don't have any errors. 注释工作正常,没有任何错误。 Here are my Gradle dependencies which I added Lombok in it. 这是我的Gradle依赖项,我在其中添加了Lombok。
compileOnly "org.projectlombok:lombok:1.16.18"
annotationProcessor "org.projectlombok:lombok:1.16.18"
I have a problem with Annotation Processors
too. 我的Annotation Processors
也有问题。
I have followed these steps: 我已按照以下步骤操作:
file>other settings>default settings
i have enabled the Annotation Processors
在file>other settings>default settings
我已启用Annotation Processors
Invalidate Caches / Restart
我有Invalidate Caches / Restart
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. 在project settings
, Annotation Processors
project settings
突然出现在Build, Execution, Deployment>Compiler
菜单下,它在Invalidating Cache
之前不存在,我检查它的勾选。 when the Android Studio restarts the Annotation Processors
setting is gone but the plugin doesn't show any errors. 当Android Studio重新启动时, Annotation Processors
设置已消失,但插件未显示任何错误。
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. 这就是我定义模型的方法,并且无法从中获取getUserId。
我做完上面的工作后修复了这个我重新启动我的电脑,突然一切都工作正常
Same issue for me. 同样的问题对我来说。 Android Studio 3.2 default config. Android Studio 3.2默认配置。
-Installed Lombok plugin -Added the following to app dependencies compileOnly 'org.projectlombok:lombok:1.18.4' annotationProcessor 'org.projectlombok:lombok:1.18.4'
-Installed Lombok插件 - 为app依赖compileOnly 'org.projectlombok:lombok:1.18.4' annotationProcessor 'org.projectlombok:lombok:1.18.4'
添加了以下内容compileOnly 'org.projectlombok:lombok:1.18.4' annotationProcessor 'org.projectlombok:lombok:1.18.4'
And Lombok annotations were just ignored. 而Lombok注释只是被忽略了。 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. 重启Android Studio后,我得到了事件日志,说Lombok需要注释处理,但是Preferences / Build Exec ... / Compiler没有显示任何内容。
File / Invalidate caches restart did the trick. File / Invalidate缓存重启就行了。 After that I could see the annotation processors option. 之后我可以看到注释处理器选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.