Commit f15dafe6 authored by Yohann Roussel's avatar Yohann Roussel
Browse files

Do not generate empty dex in multidex.

This was possible when the first class considered for adding in a dex was too
big to be sure it will fit. Now DX will try to add the class in the current dex
and crash if the class causes one index to overflow.

Change-Id: Ia1f8f733ee49e24bbb42db335ac9080312c1907a
parent d09fa663
......@@ -712,7 +712,10 @@ public class Main {
int maxFieldIdsInDex = numFieldIds + constantPoolSize + cf.getFields().size() +
MAX_FIELD_ADDED_DURING_DEX_CREATION;
if (args.multiDex && ((maxMethodIdsInDex > args.maxNumberOfIdxPerDex) ||
if (args.multiDex
// Never switch to the next dex if current dex is already empty
&& (outputDex.getClassDefs().items().size() > 0)
&& ((maxMethodIdsInDex > args.maxNumberOfIdxPerDex) ||
(maxFieldIdsInDex > args.maxNumberOfIdxPerDex))) {
DexFile completeDex = outputDex;
createDexFile();
......
......@@ -323,7 +323,7 @@ public final class DexFile {
*
* @return {@code non-null;} the class definitions section
*/
/*package*/ ClassDefsSection getClassDefs() {
public ClassDefsSection getClassDefs() {
return classDefs;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment