[英]Generate Signed APK Errors
When I run an application in the emulator it works, but when I want to generate a signed APK I get the following error message: 当我在模拟器中运行应用程序时,它可以运行,但是当我想要生成签名的APK时,出现以下错误消息:
[Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
[错误:任务':app:transformClassesWithDexForRelease'的执行失败。 > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536]
> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536]
What does this error message mean and is there a way to solve this issue? 此错误消息是什么意思,有没有办法解决此问题?
DexIndexOverflowException:
Overflow mean a limit has been reached. DexIndexOverflowException:
溢出表示已达到限制。
Your dex
file size has reached it's limit ie 64K so you need to implement Multidex
support into your project follow the official link of docs 您的
dex
文件大小已达到极限,即64K,因此您需要在项目中实现Multidex
支持,请遵循docs的官方链接
or 要么
add below to build.gradle to enable multidex support 在build.gradle中添加以下内容以启用Multidex支持
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
set the app name multidex support in your manifest application tag 在清单应用程序标记中设置应用程序名称multidex支持
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
And if you have an application class then enable dex before super.onCreate
而且,如果您有应用程序类,则在
super.onCreate
之前启用dex。
MultiDex.install(getTargetContext());
super.onCreate(arguments);
Some tricks might handy : Remove unwanted dependencies ,files and use specific google play dependency like gms etc instead of adding it as a whole plus you can use best practice for proguard rules follow the link for an example 有些技巧可能会派上用场:删除不需要的依赖关系,文件,并使用像克等,而不是将其作为一个整体,再加上你可以使用最佳实践proguard的具体规则玩谷歌的依赖按照链接为例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.