【问题标题】:Error:Execution failed for task ':app:javaPreCompileDebug'. Android 3.0+ lombok错误:任务“:app:javaPreCompileDebug”的执行失败。 Android 3.0+ 龙目岛
【发布时间】:2017-11-04 15:05:43
【问题描述】:

我想在 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"

【问题讨论】:

  • 好的,你试过了吗:compile 'org.projectlombok:lombok:1.16.18' annotationProcessor "org.projectlombok:lombok:1.16.18"
  • 是的。但我收到错误 - 错误:(19, 1) 错误: 包 javax.annotation 不存在
  • 那么这应该可以工作:compileOnly 'javax.annotation:javax.annotation-api:1.2' compileOnly "org.projectlombok:lombok:1.16.18" annotationProcessor "org.projectlombok:lombok:1.16.18"

标签: android gradle lombok android-studio-3.0


【解决方案1】:

试试

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

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

lombok.addGeneratedAnnotation = false

请参阅configuration documentation 了解更多信息。

【讨论】:

    猜你喜欢
    • 2018-12-01
    • 2016-10-26
    • 1970-01-01
    • 2015-05-13
    • 2016-09-02
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多