Similarly to this question, I received the following error:
[INFO] --- android-maven-plugin:3.3.0:dex (default-dex) @ betodef-android ---
[INFO] /usr/lib/jvm/java-6-sun-1.6.0.32/jre/bin/java [-Xmx1024M, {snip}
[INFO]
[INFO] UNEXPECTED TOP-LEVEL ERROR:
[INFO] java.lang.OutOfMemoryError: GC overhead limit exceeded
This occurred after I added several dependencies, including fastutil, to my Android project. However, increasing the memory available for dex does not solve the problem.
The problem lies in a limit of the
dexformat, specifically the 65536 limit on the number of method references.To diagnose the problem, increase the memory to a much larger amount (enabling debugging/verbose output doesn’t help, curiously enough). In my case, I added the following to the
android-maven-pluginconfiguration:After choosing a large-enough heap size, the message changes to include something like this:
As you can see, there is a huge amount of references in the fastutil classes.
There are two possible solutions of this problem: