Android Studio 3.+ 集成 ButterKnife8.8.1错误

   个人比较追新,Studio总是用最新的,很久没有建项目了,这几天需要新建项目,才发现以前一股脑就集成的插件,总是遇到问题,颇为震惊!!!!!!!!!

   我先是跟着Github的指导集成的,发现这个找不到,那个有冲突,

我用的Android Studio 3.3 Canary 4 (当前最新)

app buidle.gradle

buildscript {
    
    repositories {
        google()
        jcenter()
        mavenCentral()//<------
    }
    dependencies {
        
        classpath 'com.android.tools.build:gradle:3.1.4' //<-------
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0' //<-------
    }
}

module buidle.gradle

apply plugin: 'com.android.application'
//<----------------------  这里不用 apply Github上的
//apply plugin: 'com.android.library'
//apply plugin: 'com.jakewharton.butterknife'
android {
   ............................
}

dependencies {
    ....................
    implementation 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}

依赖的Module 中使用 ButterKnife

apply plugin: 'com.android.application' 
apply plugin: 'com.jakewharton.butterknife'//就需要这里了
android {
   ............................
}

dependencies {
    ....................
    // 一样需要引入
    implementation 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}


绑定View 使用R2.id.***

@BindView(R2.id.base_back_container)
LinearLayout back_container;

任何module中使用Butterknife 都要引入

implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

下面的只需要在引入的Module中apply就可以了

apply plugin: 'com.jakewharton.butterknife'//这里就需要了

根据大家说的降级提示,我最开始 gradle 版本 3.0.0 也行 (当然这里降了,com.android.***** 的支持库也要相应的降版本)
 这里是  gradle  butterknife 版本有一个对应关系,

顺便说一句, recycleview 的支持不再是以前的  com.android.support 而是下面的这个 androidx.***

  implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc01'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-rc01'

目前也有一些可以继续使用的

implementation 'com.android.support:multidex:1.0.3'


这是我找到 gradle  butterknife 版本 最高的 可用的了,如有其它的对应关系,欢迎留言

猜你喜欢

转载自blog.csdn.net/qq_19973845/article/details/81475133