annotationProcessor:Annotation processors must be explicitly declared ...

QuibblerQuibbler 2020-03-08 约 5 分钟 3021 次阅读

Annotation processors must be explicitly declared now

可能是因为昨天晚上更新了AndroidStudio,第二天早上打开编译运行不了,报错(为什么每次更新AndroidStudio总会搞些事情):

        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.

        - jetified-compiler-4.11.0.jar (com.github.bumptech.glide:compiler:4.11.0)

        - jetified-butterknife-compiler-10.2.1.jar (com.jakewharton:butterknife-compiler:10.2.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.

build.gradle中还提示修改一些依赖库的编译选项,不要使用implementation,换成annotationProcessor:

好吧,既然官方推荐这么做,就将提示的全部换成annotationProcessor。没想到编译各种找不到库,为什么一团乱码,参考《AndroidStudio各种中文乱码 》

看来提示也是有问题的,AndroidStudio老毛病了。compiler库用关键字annotationProcessor,代码库用implementation关键字导入。

//Butter Knife
    //noinspection AnnotationProcessorOnCompilePath    如果还嫌提示烦就Supress
    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
    
    //Glide依赖
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

还有另一种方法,报错信息以及给出了:android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true,不过这种方式已经被标记为deprecate。

android {
        ...
        defaultConfig {
            ...
            javaCompileOptions {
                annotationProcessorOptions {
                    includeCompileClasspath = true
                }
            }
        }
        ...
    }

相关推荐

获取系统SDK版本、判断手机ROM
精选Code

获取系统SDK版本、判断手机ROM

Build获取系统SDK版本Android中部分API的使用,需要在特定的SDK版本之后才能使用,因此在兼容老版本SDK的时候,经常需要判断API的版本。各种Android版本的对应关系参考《Android各版本对应的SDK版本》判断手机ROM有时候需要判断手机系统的ROM,检测ROM是MIUI、EMUI还是Flyme,可以使用getprop命令,去系统build.prop文件(关于build.p

4.3k
AndroidStudio中各种中文乱码问题
精选Code

AndroidStudio中各种中文乱码问题

AndroidStudio中各种中文乱码问题1、编译Java错误信息乱码在出现这个Annotation processors must be explicitly declared now...问题的时候,正好也发现AndroidStudio Build Output错误信息都乱码。经常遇到各种问题,习惯了,现在遇到的问题,都是以后的答案。 1.1、修改项目build.gradle(无效)在整个p

2.8k
Function Calling 详解:让大模型调用你的函数
精选Code

Function Calling 详解:让大模型调用你的函数

问大模型“北京今天多少度”,它只能用训练数据里的旧知识猜,或者老实承认不知道。但如果告诉它“我这里有个查天气的接口”,它会说:“帮我调用 get_weather,城市参数填北京。”你的程序执行调用,把结果递回去,它再组织成一句自然的回答。Function Calling(函数调用)让模型从“只会聊天”进化为“会办事”——它是大模型连接外部世界的第一块基石,也是一切 Agent 系统的地基。本文按“…

108