简体   繁体   中英

Gradle assembleRelease doesn't work with ProGuard

So my project seemed to break at random today, with the error apparently being something about being over 65K methods. After doing some research I realised it was time to use ProGuard and enable multiDex, which seemes to have made things worse. This is the error I get when I try create a release APK:

Error:Execution failed for task ':My-Project:proguardRelease'.

java.io.IOException: Can't write [C:\\Users\\User-PC\\AndroidStudioProjects\\MyProject\\My-Project\\build\\intermediates\\classes-proguard\\release\\classes.jar] (Can't read [C:\\Users\\User-PC\\AndroidStudioProjects\\MyProject\\My-Project\\libs\\bolts-android-1.2.0.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [a/a.class == bolts-android-1.2.0.jar:bolts/AggregateException.class]))

and my build.gradle file looks like this:

apply plugin: 'com.android.application'
apply plugin: 'com.parse'

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.parse.com/repo' }
    }
    dependencies {
        classpath 'com.parse.tools:gradle:1.+'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile fileTree(include: 'ParseCrashReporting-*.jar', dir: 'libs')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.github.dkharrat.nexusdialog:nexusdialog:0.2.0'
}

android {
    signingConfigs {
        config {
           // stuff
        }
    }
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        applicationId "com.kusasa.saleboat"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 8
        versionName "1.0.7"
        // Enabling multidex support.
        multiDexEnabled true
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
    productFlavors {
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          signingConfig signingConfigs.config
            debuggable false
        }
    }
}

I have tried cleaning and rebuilding the project several times, to no avail.

Well i think you get this error because you declare two dependencies of bolts-android one in My-Project\\libs\\bolts-android-1.2.0.jar the other usinge maven with compile 'com.parse.bolts:bolts-android:1.+'

Remove the lib that's on the lib folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM