本文介绍了MultiDex:启用MultiDex后,主要Dex容量超过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个包含在我的项目中的,需要MultiDex的程序包,我有156561个引用,所以我需要多个.dex文件.

I'm using a package I've included into my project that requires MultiDex, I've got 156561 references so I'll need multiple .dex files.

但是失败了,理由是主dex文件太大

However it fails, citing that the main dex file is too large

有人建议使用keepRuntimeAnnotatedClasses false,但我使用的是Xamarin,尚不清楚在没有Gradle的情况下如何实现这一点.

Some suggested using keepRuntimeAnnotatedClasses false, but I'm using Xamarin and its not clear on how to accomplish this without Gradle.

其他人建议设置最低API> 21,这对于我的项目已经是正确的.

Others suggest setting the minimum API > 21, which is already true for my project.

我还手动升级了Proguard,因为MultiDex使用它并获得了最新的1.8 JDK

I've also manually upgraded Proguard, as MultiDex uses it and got the newest 1.8 JDK

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:548)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:368)
at com.android.dx.command.dexer.Main.runDx(Main.java:289)
at com.android.dx.command.dexer.Main.main(Main.java:247)
at com.android.dx.command.Main.main(Main.java:94)

我认为MultiDex将是太多类"的解决方案.但是,似乎决定填充主dex文件的任何逻辑都超过了填充

I would think that MultiDex would be the solution to 'Too many classes'. However it seems like whatever logic is deciding to fill the main dex file is over filling it

推荐答案

假设您使用的是Xamarin.Android的最新版本,则可以尝试使用新的" Google D8 dex工具,而不是Proguard. >

Assuming you are using one of the latest versions of Xamarin.Android, you can try using the "new" Google D8 dex tool vs. using Proguard.

<PropertyGroup>
   <AndroidDexTool>d8</AndroidDexTool>
   <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>

  • Android的D8 dexer和R8收缩器

    • Android’s D8 dexer and R8 shrinker
    • 有关各种D8/R8项目配置的详细信息,可以在Xamarin.Android存储库中找到:

      Detailed info on the various D8/R8 project configurations can be found in the Xamarin.Android repo here:

      这篇关于MultiDex:启用MultiDex后,主要Dex容量超过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:47