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

时间:2017-10-26 20:45:09

标签: 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.

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

5 个答案:

答案 0 :(得分:17)

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

annotationProcessor 'com.google.auto.value:auto-value:1.1'

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

答案 1 :(得分:15)

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

    Find duplicate Records:

    Suppose we have table : Student 
    student_id int
    student_name varchar
    Records:
    +------------+---------------------+
    | student_id | student_name        |
    +------------+---------------------+
    |        101 | usman               |
    |        101 | usman               |
    |        101 | usman               |
    |        102 | usmanyaqoob         |
    |        103 | muhammadusmanyaqoob |
    |        103 | muhammadusmanyaqoob |
    +------------+---------------------+

    Now we want to see duplicate records
    Use this query:


   select student_name,student_id ,count(*) c from student group by student_id,student_name having c>1;

+--------------------+------------+---+
| student_name        | student_id | c |
+---------------------+------------+---+
| usman               |        101 | 3 |
| muhammadusmanyaqoob |        103 | 2 |
+---------------------+------------+---+

希望它解决了某人的问题

答案 2 :(得分:1)

添加annotationProcessor依赖项对我来说不起作用,而是将此行放在build.gradle内的任意位置工作:

android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true

答案 3 :(得分:0)

可以使用annotationProcessor 代替 implementation/compile声明,而不像我们以前声明的那样。

implementation 'com.google.auto.value:auto-value:1.1' 

compile 'com.google.auto.value:auto-value:1.1' 

应替换为

annotationProcessor 'com.google.auto.value:auto-value:1.1'

答案 4 :(得分:0)

对我来说,发生此问题是因为jitpack未被放置为根等级的最后一个条目。

allprojects {
    repositories {
        // ... other repositories
        maven { url "https://jitpack.io" }
    }
}

该解决方案来自https://github.com/permissions-dispatcher/PermissionsDispatcher/issues/535#issuecomment-432190926

中的@hotchemi评论