使用proguard构建Android项目

时间:2015-10-24 09:21:33

标签: android gradle build proguard

我正在用proguard构建我的Android应用程序,但是我得到了一大堆警告,我的构建经常失败。为什么是这样?我一直在努力做研究,但我无法弄明白。我复制了一个包还是什么?我不明白。这是我的Gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.20.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"
    defaultConfig {
        multiDexEnabled true
        applicationId "com.test.test"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 2
        versionName "1.0"
    }
    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
    }

    sourceSets.main {
        jni.srcDirs = [] //Disable automatic ndk-build call
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    packagingOptions {
//        exclude 'META-INF/DEPENDENCIES.txt'
//        exclude 'META-INF/LICENSE.txt'
//        exclude 'META-INF/NOTICE.txt'
//        exclude 'META-INF/NOTICE'
//        exclude 'META-INF/LICENSE'
//        exclude 'META-INF/DEPENDENCIES'
//        exclude 'META-INF/notice.txt'
//        exclude 'META-INF/license.txt'
//        exclude 'META-INF/dependencies.txt'
//        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

repositories {
    maven {
        // Zendesk public repo
        url 'https://zendesk.artifactoryonline.com/zendesk/repo/'
    }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
//    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'org.jsoup:jsoup:1.8.2'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.squareup.picasso:picasso:2.*'
    compile 'com.zopim.android:sdk:1.0.1'
    compile 'com.android.support:support-v13:23.0.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    compile "com.google.android.gms:play-services-gcm:8.1.0"
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile('com.twitter.sdk.android:twitter:1.9.0@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
}

以下是警告:“

Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/maven/commons-io/commons-io/pom.properties] (Duplicate zip entry [META-INF/maven/commons-io/commons-io/pom.properties])
Warning: can't write resource [META-INF/maven/commons-io/commons-io/pom.xml] (Duplicate zip entry [META-INF/maven/commons-io/commons-io/pom.xml])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [META-INF/NOTICE.txt])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\bolts-android-1.1.4.jar--1340461342]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--1024448806]

Warning: can't write resource [fabric/io.fabric.sdk.android.fabric.properties] (Duplicate zip entry [fabric/io.fabric.sdk.android.fabric.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--1298675938]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--189103278]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--287821166]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--369234074]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--388051675]

Warning: can't write resource [fabric/com.twitter.sdk.android.tweet-composer.properties] (Duplicate zip entry [fabric/com.twitter.sdk.android.tweet-composer.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--458147245]

Warning: can't write resource [fabric/com.crashlytics.sdk.android.beta.properties] (Duplicate zip entry [fabric/com.crashlytics.sdk.android.beta.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--517528253]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--54104765]

Warning: can't write resource [fabric/com.crashlytics.sdk.android.answers.properties] (Duplicate zip entry [fabric/com.crashlytics.sdk.android.answers.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--626674261]

Warning: can't write resource [fabric/com.twitter.sdk.android.tweet-ui.properties] (Duplicate zip entry [fabric/com.twitter.sdk.android.tweet-ui.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--637237816]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--842751982]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar--999571865]

Warning: can't write resource [fabric/com.twitter.sdk.android.twitter.properties] (Duplicate zip entry [fabric/com.twitter.sdk.android.twitter.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-1335521591]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-1366692765]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-2009840117]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-215010498]

Warning: can't write resource [fabric/com.twitter.sdk.android.twitter-core.properties] (Duplicate zip entry [fabric/com.twitter.sdk.android.twitter-core.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-236032957]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-286038234]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-387796437]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-388902037]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-429756367]

Warning: can't write resource [fabric/com.digits.sdk.android.digits.properties] (Duplicate zip entry [fabric/com.digits.sdk.android.digits.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-545673352]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-608250876]

Warning: can't write resource [fabric/com.crashlytics.sdk.android.crashlytics.properties] (Duplicate zip entry [fabric/com.crashlytics.sdk.android.crashlytics.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-776065640]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\classes.jar-840967979]

Warning: can't write resource [fabric/com.crashlytics.sdk.android.crashlytics-core.properties] (Duplicate zip entry [fabric/com.crashlytics.sdk.android.crashlytics-core.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\commons-io-2.4.jar-2115553081]

Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/maven/commons-io/commons-io/pom.properties] (Duplicate zip entry [META-INF/maven/commons-io/commons-io/pom.properties])
Warning: can't write resource [META-INF/maven/commons-io/commons-io/pom.xml] (Duplicate zip entry [META-INF/maven/commons-io/commons-io/pom.xml])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [META-INF/NOTICE.txt])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\commons-lang3-3.3.2.jar-1007033638]

Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/maven/org.apache.commons/commons-lang3/pom.properties] (Duplicate zip entry [META-INF/maven/org.apache.commons/commons-lang3/pom.properties])
Warning: can't write resource [META-INF/maven/org.apache.commons/commons-lang3/pom.xml] (Duplicate zip entry [META-INF/maven/org.apache.commons/commons-lang3/pom.xml])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [META-INF/NOTICE.txt])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\gson-2.3.jar-1973338614]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\internal_impl-23.0.0.jar-1325014075]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\internal_impl-23.0.1.jar--1647584481]
Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\jackson-annotations-2.5.1.jar--3007364]

Warning: can't write resource [META-INF/LICENSE] (Duplicate zip entry [META-INF/LICENSE])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-annotations/pom.properties] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-annotations/pom.properties])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-annotations/pom.xml] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-annotations/pom.xml])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\jackson-core-2.5.1.jar-1693462070]

Warning: can't write resource [META-INF/LICENSE] (Duplicate zip entry [META-INF/LICENSE])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml])
Warning: can't write resource [META-INF/NOTICE] (Duplicate zip entry [META-INF/NOTICE])
Warning: can't write resource [META-INF/services/com.fasterxml.jackson.core.JsonFactory] (Duplicate zip entry [META-INF/services/com.fasterxml.jackson.core.JsonFactory])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\jackson-databind-2.5.1.jar-1672419792]

Warning: can't write resource [META-INF/LICENSE] (Duplicate zip entry [META-INF/LICENSE])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.properties] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.properties])
Warning: can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml] (Duplicate zip entry [META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml])
Warning: can't write resource [META-INF/NOTICE] (Duplicate zip entry [META-INF/NOTICE])
Warning: can't write resource [META-INF/services/com.fasterxml.jackson.core.ObjectCodec] (Duplicate zip entry [META-INF/services/com.fasterxml.jackson.core.ObjectCodec])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\jsoup-1.8.2.jar-1706156608]

Warning: can't write resource [META-INF/maven/org.jsoup/jsoup/pom.properties] (Duplicate zip entry [META-INF/maven/org.jsoup/jsoup/pom.properties])
Warning: can't write resource [META-INF/maven/org.jsoup/jsoup/pom.xml] (Duplicate zip entry [META-INF/maven/org.jsoup/jsoup/pom.xml])
Warning: can't write resource [org/jsoup/nodes/entities-base.properties] (Duplicate zip entry [org/jsoup/nodes/entities-base.properties])
Warning: can't write resource [org/jsoup/nodes/entities-full.properties] (Duplicate zip entry [org/jsoup/nodes/entities-full.properties])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\library-2.4.0.jar-1517600754]

Warning: can't write resource [META-INF/maven/com.nineoldandroids/library/pom.properties] (Duplicate zip entry [META-INF/maven/com.nineoldandroids/library/pom.properties])
Warning: can't write resource [META-INF/maven/com.nineoldandroids/library/pom.xml] (Duplicate zip entry [META-INF/maven/com.nineoldandroids/library/pom.xml])

Copying resources from program directory [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\org.apache.commons.io-2.4.jar-1391110299]

Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lib/commons-io-2.4.jar:META-INF/MANIFEST.MF])
Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [lib/commons-io-2.4.jar:META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [lib/commons-io-2.4.jar:META-INF/NOTICE.txt])

Warning: Exception while processing task java.io.IOException: Can't write [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\FULL_PROJECT\proguard\release\classes.jar] (Can't read [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\org.apache.commons.io-2.4.jar-1391110299] (Duplicate zip entry [lib/commons-io-2.4.jar:org/apache/commons/io/ByteOrderMark.class]))
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
        > java.io.IOException: Can't write [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\FULL_PROJECT\proguard\release\classes.jar] (Can't read [D:\OneDrive\Documenten\app\app\build\intermediates\transforms\CLASSES_and_RESOURCES\EXTERNAL_LIBRARIES\extractJars\release\org.apache.commons.io-2.4.jar-1391110299] (Duplicate zip entry [lib/commons-io-2.4.jar:org/apache/commons/io/ByteOrderMark.class]))

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

        BUILD FAILED

0 个答案:

没有答案