[Android] DexException: Too many classes in --main-dex-list, main dex capacity exceeded

551 views
Skip to first unread message

Андрей Кадацкий

unread,
Dec 20, 2017, 11:45:39 AM12/20/17
to Chromium-dev
Hi, I have some custom Chrome build for Android based on the latest M60 version ( commit 9401d9831c2aac159f08d6be1437c121cd79c229 )
I want to build debug and release chrome_public_apk

Build config for debug is:
target_os = "android"
is_debug = true
target_cpu = "arm"
is_component_build = true
is_clang = true
enable_incremental_javac = true

I enabled multidex for both debug/release builds (enable_multidex = true variable in config).
I added some libs in jar format and it works ok. After that I added few more jar libs, and now I can't compile debug build. Release build (processed by Proguard) works ok.

With debug build I have compile-time issue:
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:546)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
at com.android.dx.command.dexer.Main.run(Main.java:275)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)

It fails on command:
../third_party/android_tools/sdk/build-tools/25.0.2/dx -JXmx2G --num-threads=8 --dex --force-jumbo --output gen/chrome/android/chrome_public_apk/classes.dex.zip --multi-dex --minimal-main-dex --main-dex-list=gen/chrome/android/chrome_public_apk/classes.dex.zip.main_dex_list  ...list_of_my_jar_files...

it refers to https://bugs.chromium.org/p/chromium/issues/detail?id=712852 which is fixed in M59, but I have the same issue in M60.

How to avoid this issue?

Андрей Кадацкий

unread,
Dec 21, 2017, 11:33:29 AM12/21/17
to Chromium-dev
Update build-tools from 25.0.2 to 27.0.2 has solved an issue.

Debin Zhang

unread,
Jul 3, 2019, 3:17:37 PM7/3/19
to Chromium-dev
Can you explain in which config file you turn on "enable_multidex = true"?

Seems Chromium only enabled multidex for debug build. Now I am trying to make a release build with multidex enabled. I tried to add "enable_multidex=true"  in args.gn,  chrome/android/BUILD.gn.  or chrome/android/chrome_public_apk_tmpl.gni (set multidex_in_release=true). But I got a message: "Assignment had no effect".  

I am building release public_apk on Chromium 74.

Thanks in advance.

Sam Maier

unread,
Jul 3, 2019, 3:35:20 PM7/3/19
to debin...@gmail.com, Chromium-dev
You can set it in chrome/android/BUILD.gn for chrome_public_apk. As for why it's saying "Assignment had no effect", it's likely because we don't support multidex with R8 like we did with Proguard. We are quite far away from the multidex limit, and adding main dex rules bloats our one dex file since R8 can't optimize across the main dex boundary, so we decided not to allow it. If you really need that functionality back, you will have to edit build/config/android/internal_rules.gni and change the proguard() part of the dex template.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/3ba626f3-8c8e-406d-bcd1-a010a8c69725%40chromium.org.
Reply all
Reply to author
Forward
0 new messages