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,一整且正常了。