Android Studio3.0使用Butterknife注解框架报错及其解决方案

前言:现在用的AS是3.0的,今天在编译运行之前使用AS 2.1写的一个Demo时,出现了使用下面这个问题:
这里写图片描述
原因分析:新版本AS3.0在使用注释处理器时,必须显式声,而在项目中依赖于编译类路径中的Butterknife jar包含有注释处理器,因此需要将它添加到annotationprocessor配置。事实上,报错信息已经给出了我们这个问题的解决方案,即:“set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true ”

解决方案:在Model中的build.gradle文件中添加如下配置,之后,进行“sync”操作即可:

android {
    ......
    ......

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

    }
    }

有说的不对的地方,欢迎大神指出,希望能给大家提供解决问题的思路,谢谢。

猜你喜欢

转载自blog.csdn.net/ygz111111/article/details/79812706