Fork me on GitHub

android3&牛油刀-butterknife问题

原先使用的Androidstudio版本为2.2,最近换成了3.1.2,用下来发现,3.1.2有不少坑需要踩

今天总结常用的butterknife框架

现象:

按照github上的要求进行配置,报资源找不到的错误

原因:

sdk和butterknife的版本问题

解决方法:

按如下配置,将sdk改成27

butterknife版本改成8.8.1

配置代码如下,其他的还是和github要求一致即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.yinde.myapplication"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
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'
}
-------------本文结束感谢阅读-------------