Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process

今天把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 中


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章