文章目录

    • 对butterknife的版本要求
    • gradle脚本配置
      • project脚本
      • module脚本
    • module脚本注意

对butterknife的版本要求

Android Studio3.3配置butterknife对版本有要求,9.0.0-r2以上

但butterknife10.0.0只支持Androidx

As mentioned in the change log, 10.0.0 only supports AndroidX-enabled projects. If you have not yet migrated to AndroidX you need to use 9.0.0 for now.

如果没有使用androidx配置butterknife10.0.0会报这个异常

[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)

这里的配置没有使用androidx,是android

gradle脚本配置

project脚本

buildscript {    repositories {        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }        jcenter()        google()    }    dependencies {        classpath 'com.android.tools.build:gradle:3.3.0'        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }        jcenter()        google()    }}task clean(type: Delete) {    delete rootProject.buildDir}

module脚本

apply plugin: 'com.android.application'android {    compileSdkVersion 28    defaultConfig {        applicationId "pdsu.xps.blacklisttest"        minSdkVersion 18        targetSdkVersion 28        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"        compileOptions {            sourceCompatibility JavaVersion.VERSION_1_8            targetCompatibility JavaVersion.VERSION_1_8        }    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'        }    }}dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    //noinspection GradleCompatible    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'    implementation 'com.android.support.constraint:constraint-layout:1.1.3'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'    implementation 'com.jakewharton:butterknife:9.0.0-rc1'    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'}

module脚本注意

如果出现如下错误
Error: Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()
在module脚本中的androiddefaultConfig中添加以下内容,或可解除错误

compileOptions {    sourceCompatibility JavaVersion.VERSION_1_8    targetCompatibility JavaVersion.VERSION_1_8}

更多相关文章

  1. Ubuntu12.04编译ANDROID ICS出错解决方法
  2. ArcGIS for Android(安卓)在Eclipse上的安装配置 (上:下载篇)
  3. Glide框架V3版本和V4版本区别
  4. 查看Android源码的版本方法
  5. adb.exe无法运行,提示0xc000007b错误
  6. Android反编译工具apktool
  7. 同时使用AndroidX库和bufferknife库报 package android.support.
  8. android 微博开发问题
  9. android常见异常

随机推荐

  1. 模拟器上安装Android(安卓)Market
  2. 《Android安全机制解析与应用实践》笔记
  3. Handler完全重新理解
  4. Android(安卓)进程保活招式大全(转)
  5. Android线程模型
  6. Android开发者不可或缺的四大工具
  7. Study on Android【五】--自定义ContentP
  8. Android(安卓)进程管理
  9. 配置Vim开发Android详解
  10. 2013学Android不得不看的13个视频课程(共