今天把android studio 升級到了3.2之後發現了很多問題,暫時記錄如下:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/xxx/.gradle/caches/transforms-1/files-1.1/butterknife-runtime-9.0.0-rc2.aar/020f27787defbf924ab1f60f13609c35/jars/classes.jar
image.png
在網上也找了好半天方法,最後發現問題的解決方式很簡單,只需要在 build.gradle(Module:app) 文件中添加兩行代碼就可以:
// 這裏是需要添加代碼
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
這裏是我的完整代碼
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 28
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 1.8
targetCompatibility 1.8
}
}
問題的原因是:發現如果你的module 中使用了 Java1.8,那你必須也要添加以上代碼到你的app gradle 中