![](/img/trans.png)
[英]Android App Unable to generate signed apk with error com.android.build.api.transform.TransformException: java.util.zip.ZipException:
[英]generate signed APK error : java.util.zip.ZipException
我使用三星A5测试应用程序,该项目在我的手机上正常运行,但在其他手机上无法正常工作。 所以我想从我的项目中Generate signed APK
。 但是出现异常错误:
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;
我用错误搜索了这些代码,这些代码删除了该错误:
multiDexEnabled true
和
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
但是现在有另一个例外:
Error:Execution failed for task ':transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/daimajia/androidanimations/library/BaseViewAnimator.class
我认为这可能是因为我使用了库,但不知道如何处理它。 以下是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'
}
一些东西...
首先,我将删除您包含的大多数第三方库。 例如,
//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'
所有这些都由Google的设计支持库提供
我认为您也可以从名称中删除
compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
compile files('libs/volley.jar')
应该替换为compile 'com.android.volley:volley:1.0.0'
而且我也会删除
//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'
compile 'org.apmem.tools:layouts:1.10@aar'
您所包括的许多项目都已经两年多没有从事过了。 尝试仍然使用Google的支持库。 您将从Design支持库中获得大部分信息。
最后一点。 由于该应用程序包括所有这些库并通过了64k方法限制,因此您遇到了Dex错误。 我建议启用Proguard删除未使用的代码并减少项目的方法数量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.