必须立即显式声明注释处理器

Ank*_*ava 30 java android

Error:Execution failed for task ':laMusique2May2016:javaPreCompileRelease'.
> 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.
    - auto-value-1.1.jar (com.google.auto.value:auto-value:1.1)
  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.
Run Code Online (Sandbox Code Playgroud)

我看到了这个问题,但问题是auto-value-1.1.jar不在我的gradle文件中

小智 26

即使我有同样的问题,最后我通过添加到应用程序级gradle文件解决了我的问题

android{
....
    defaultConfig{
....
    javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }
}
buildTypes {
...
}
Run Code Online (Sandbox Code Playgroud)

希望它解决了某人的问题

  • **已弃用,请勿使用** (4认同)

Jon*_*Jon 23

您应该在gradle中明确添加注释处理器.将以下内容放在gradle依赖项中应修复它:

annotationProcessor 'com.google.auto.value:auto-value:1.1'
Run Code Online (Sandbox Code Playgroud)

但是,正如其他人已经提到的那样,您应该弄清楚哪些现有依赖项使用自动值来断言您是否确实需要它.注释处理器最终会减慢构建时间,因此如果不必要,请不要包含它.