bazel: CompatDx cannot fit requested classes in a single dex file
Description of the bug:
After updating to rolling release 6.0.0-pre.20220526.1
, CompatDx
produces a massive amount of warnings and eventually fails with the following error:
Error: Cannot fit requested classes in a single dex file (# methods: 227417 > 65536 ; # fields: 124517 > 65536). Try supplying a main-dex list
Exception in thread "main" java.lang.AssertionError: Failure
at com.google.devtools.build.android.r8.CompatDx.main(CompatDx.java:478)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
at Version.fakeStackEntry(Version_3.3.28.java:0)
at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75)
at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27)
at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2)
at com.android.tools.r8.D8.run(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6)
at com.google.devtools.build.android.r8.CompatDx.run(CompatDx.java:624)
at com.google.devtools.build.android.r8.CompatDx.main(CompatDx.java:472)
Caused by: com.android.tools.r8.internal.f: Cannot fit requested classes in a single dex file (# methods: 227417 > 65536 ; # fields: 124517 > 65536)
at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14)
at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
at com.android.tools.r8.internal.h30.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:524)
at com.android.tools.r8.internal.c30.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:7)
at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:371)
at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:455)
at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:756)
at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1)
at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24)
... 4 more
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
You might need to have a classpath large enough to exceed a single dex file to reproduce this.
We are using the following dexing configuration with multidex
mode set to native
:
# Enable experimental d8 merger
build --define=android_dexmerger_tool=d8_dexmerger
build --define=android_incremental_dexing_tool=d8_dexbuilder
build --define=android_standalone_dexing_tool=d8_compat_dx
Reverting this PR resolves the issue. More specifically just reverting the changes in tools/android/android_sdk_repository_template.bzl
is enough to build successfully again.
Which operating system are you running Bazel on?
Mac OS
What is the output of bazel info release
?
6.0.0-pre.20220526.1
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 39 (39 by maintainers)
Commits related to this issue
- Fix Dexing.java after https://github.com/bazelbuild/bazel/commit/883ce21af30c0e1b331d749c4f20c63f3f5c36df. Dexing.java when packaged in bazel in the embedded tools repo relies on the options processo... — committed to bazelbuild/bazel by ahumesky 2 years ago
- Fix Dexing.java after https://github.com/bazelbuild/bazel/commit/883ce21af30c0e1b331d749c4f20c63f3f5c36df. Dexing.java when packaged in bazel in the embedded tools repo relies on the options processo... — committed to aranguyen/bazel by ahumesky 2 years ago
- Fix multidex with D8 in Bazel by setting ``` --experimental_use_dex_splitter_for_incremental_dexing --experimental_incremental_dexing_after_proguard_by_default --experimental_incremental_dexing_after_... — committed to aranguyen/bazel by ahumesky 2 years ago
- Fix Dexing.java after https://github.com/bazelbuild/bazel/commit/883ce21af30c0e1b331d749c4f20c63f3f5c36df. Dexing.java when packaged in bazel in the embedded tools repo relies on the options processo... — committed to aranguyen/bazel by ahumesky 2 years ago
- Fix multidex with D8 in Bazel by setting ``` --experimental_use_dex_splitter_for_incremental_dexing --experimental_incremental_dexing_after_proguard_by_default --experimental_incremental_dexing_after_... — committed to aranguyen/bazel by ahumesky 2 years ago
I’ve asked for the fix to be cherrypicked into 5.3.0: https://github.com/bazelbuild/bazel/pull/15917
@ahumesky opened up a new issue for the stack map able warnings here https://github.com/bazelbuild/bazel/issues/15751