错误:任务':app:javaPreCompileDebug'执行失败。 Android 3.0+ lombok

时间:2017-11-04 15:05:43

标签: android gradle lombok android-studio-3.0

我想在Android Studio 3.0中使用lombok

我收到错误

Error:Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
    - lombok-1.16.18.jar (org.projectlombok:lombok:1.16.18)
  Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
  See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

我的gradle依赖

compileOnly "org.projectlombok:lombok:1.16.18"

1 个答案:

答案 0 :(得分:1)

尝试

compile 'org.projectlombok:lombok:1.16.18' annotationProcessor "org.projectlombok:lombok:1.16.18"

您可以通过将以下行放入项目顶级目录之一的javax.annotation.Generated文件中来禁用lombok.config的生成:

lombok.addGeneratedAnnotation = false

有关详细信息,请参阅configuration documentation