MultiDex: Main Dex Capacity Exceeded with MultiDex Enabled

强颜欢笑 提交于 2019-12-13 04:11:03

问题


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.

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

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

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

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)

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


回答1:


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’s D8 dexer and R8 shrinker

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

  • This is the D8 and R8 integration specification for Xamarin.Android.


来源:https://stackoverflow.com/questions/55818155/multidex-main-dex-capacity-exceeded-with-multidex-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!