Android Studio 使用Lombok

app module的gradle文件添加以下依赖:

dependencies {
     compileOnly "org.projectlombok:lombok:1.18.6"
 }

运行起来报错了,提示去设置,按照提示找不到设置的选项,一脸懵逼呀。

 Lombok Requires Annotation Processing
 Annotation processing seems to be disabled for the project “1.0.0-snapshot”. But lombok is on classpath.
 For the lombok plugin to function correctly, please enable it under
 “Settings > Build > Compiler > Annotation Processors”

解决办法:
找到这个文件

.idea/compiler.xml
添加以下代码
component 标签下添加以下内容

<annotationProcessing>
  <profile default="true" name="Default" enabled="true"><!-- here -->
    <processorPath useClasspath="true" />
  </profile>
</annotationProcessing>

重启Android studio,一整且正常了。

原文链接:https://blog.csdn.net/a924068818/article/details/89015948

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享