summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-07-21 11:44:23 +0200
committerYohann Roussel <yroussel@google.com>2014-07-25 15:13:32 +0200
commit084b7f109aa96a86a267074f5464732b8062bd5a (patch)
tree1f62c049e1b0415caced460eecf3e2f176db443b
parentdf3707800b703224a1c5d3e23f88c2d912c5f7f6 (diff)
downloadandroid_dalvik-084b7f109aa96a86a267074f5464732b8062bd5a.tar.gz
android_dalvik-084b7f109aa96a86a267074f5464732b8062bd5a.tar.bz2
android_dalvik-084b7f109aa96a86a267074f5464732b8062bd5a.zip
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. (cherry picked from commit f15dafe674d2270cafaf4fb7993963ec474d3761) Change-Id: I323f8111c2be6bace908d0539ff324c4bd033c05
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java5
-rw-r--r--dx/src/com/android/dx/dex/file/DexFile.java2
2 files changed, 5 insertions, 2 deletions
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 406e2673b..c5f9c94f6 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -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();
diff --git a/dx/src/com/android/dx/dex/file/DexFile.java b/dx/src/com/android/dx/dex/file/DexFile.java
index 01a5e4b50..103985ce5 100644
--- a/dx/src/com/android/dx/dex/file/DexFile.java
+++ b/dx/src/com/android/dx/dex/file/DexFile.java
@@ -323,7 +323,7 @@ public final class DexFile {
*
* @return {@code non-null;} the class definitions section
*/
- /*package*/ ClassDefsSection getClassDefs() {
+ public ClassDefsSection getClassDefs() {
return classDefs;
}