Android(安卓)Studio 3.3配置Butterknife处理
16lz
2021-01-25
文章目录
- 对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脚本中的android
或defaultConfig
中添加以下内容,或可解除错误
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8}
更多相关文章
- Ubuntu12.04编译ANDROID ICS出错解决方法
- ArcGIS for Android(安卓)在Eclipse上的安装配置 (上:下载篇)
- Glide框架V3版本和V4版本区别
- 查看Android源码的版本方法
- adb.exe无法运行,提示0xc000007b错误
- Android反编译工具apktool
- 同时使用AndroidX库和bufferknife库报 package android.support.
- android 微博开发问题
- android常见异常