1. 程式人生 > >android開發:release打包Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

android開發:release打包Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

情景

專案進行release打包,結果報錯:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/widget/ViewDragHelper$Callback.class

解決

開始百度上尋找解決方法,幾乎都是說,這是專案依賴包存在相同的包,類。解決的方法是,刪除重複的JAR包。但是我的專案,沒有相同的JAR包。
折磨了半天,最後解決了這問題,更新一下app目錄下的grade檔案的v4,v7的版本,設定成一致,然後release打包成功了。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.smart.smartguanggangproject"
        minSdkVersion 19
        targetSdkVersion 25
        multiDexEnabled true
    }

    buildTypes {
        release {
//
minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.zhy:base-rvadapter:3.0.3' }