程序包com.**.****.databinding不存在 ButterKnife Databinding

程序包com..**.databinding不存在 ButterKnife Databinding

databinding不存在的问题大多数是说xml文件的问题,这个就不说了,可以随便百度,本次说的是一个项目刚开始用了ButteKnife,再使用databinding报错的情况,因为有很多文件,所以不想改。
ButterKnife简介时写的时候都会用android-apt,android-apt 作者在官网发表声明Android Gradle 插件 2.2 版本后将不会继续维护 android-apt,Android Gradle 插件提供了名为annotationProcessor 的功能来完全代替 android-apt。
1、移除 Module 的 build.gradle 文件中对 android-apt 的相关配置
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'//位置在整个项目的.gradle中
    }
}
apply plugin: 'com.neenbedankt.android-apt'//位置在你主module的.gradle中
2、将 Module 的 build.gradle 文件中使用 apt 引入的依赖修改为使用 annotationProcessor 进行引入,

修改前:

dependencies {
  compile 'com.squareup.retrofit2:retrofit:2.1.0'
  apt 'com.jakewharton:butterknife-compiler:8.2.1'
}

修改后:

dependencies {
  compile 'com.squareup.retrofit2:retrofit:2.1.0'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1'
}

地址android-apt 即将退出历史舞台
其他的databinding问题分享CloudReader

你可能感兴趣的:(Android)