简体   繁体   中英

generate signed APK error : java.util.zip.ZipException

I use my samsung A5 for testing app and the project is working correctly on my phone, but not working on other phones. so I want to Generate signed APK from my project. but there was an exception error:

Error:Execution failed for task '::transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/daimajia/androidanimations/library/BaseViewAnimator;

I googled the error and these code remove that error:

multiDexEnabled true

and

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/notice.txt'
}

but now there is another exception:

Error:Execution failed for task ':transformClassesWithJarMergingForRelease'.
 com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/daimajia/androidanimations/library/BaseViewAnimator.class

I think this might be because of libraries that I use, but have no idea how to handle it. below is all libraries in build.gradle :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    //for compiling card view
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'

    //for sticky header
    compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.melnykov:floatingactionbutton:1.0.7'

    compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'

    compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'

    compile 'me.drakeet.materialdialog:library:1.3.1'

    compile files('libs/volley.jar')

    compile 'com.daimajia.easing:library:1.0.1@aar'

    compile 'com.daimajia.androidanimations:library:1.1.3@aar'

    //Sweet Alert Dialog
    compile 'cn.pedant.sweetalert:library:1.3'

    compile 'org.apmem.tools:layouts:1.10@aar'

}

A few things...

First of all, I'd remove most of the 3rd party libraries you are including. For example,

//for sticky header
compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'

all of those are covered by the Design Support Library from Google

From the names I think you can also remove

compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'

compile files('libs/volley.jar') should be replaced with compile 'com.android.volley:volley:1.0.0'

and I'd also remove

//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'

compile 'org.apmem.tools:layouts:1.10@aar'

Many of those projects you are including haven't been worked on in over 2 years. Try to still with the support libraries from Google. You'll get most of this from the Design support library.

Last point. You are getting the Dex errors because the app is including all of these libraries and passing the 64k method limit . I suggest enabling proguard to remove un-used code and reduce the method count of your project.

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