Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayufan/7aa3c61165d64c5e590a to your computer and use it in GitHub Desktop.
Save ayufan/7aa3c61165d64c5e590a to your computer and use it in GitHub Desktop.
Added multi-dex option to Android Dex Compiler (Android Studio)
From b77c71cf504ac9bb5b105a1974e5230df09d7e97 Mon Sep 17 00:00:00 2001
From: Kamil Trzcinski <ayufan@ayufan.eu>
Date: Thu, 6 Nov 2014 17:49:22 +0100
Subject: [PATCH] Added multi-dex option to Android Dex Compiler
Change-Id: Ic9c0331371a779a6ed1a8594e0c5fbd482e5eaf6
---
.../src/org/jetbrains/jps/android/AndroidDexBuilder.java | 4 ++++
.../jps/android/builder/AndroidDexBuildTarget.java | 1 +
.../model/JpsAndroidDexCompilerConfiguration.java | 4 ++++
.../impl/JpsAndroidDexCompilerConfigurationImpl.java | 16 ++++++++++++++++
.../compiler/AndroidDexCompilerConfiguration.java | 1 +
.../compiler/AndroidDexCompilerSettingsConfigurable.form | 12 ++++++++++--
.../compiler/AndroidDexCompilerSettingsConfigurable.java | 4 ++++
7 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java b/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java
index ebec8c1..979aff4 100644
--- a/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java
+++ b/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java
@@ -289,6 +289,10 @@ public class AndroidDexBuilder extends AndroidTargetBuilder<BuildRootDescriptor,
if (configuration.isCoreLibrary()) {
programParamList.add("--coreLibrary");
}
+
+ if (configuration.isMultiDex()) {
+ programParamList.add("--multi-dex");
+ }
}
else {
vmOptions = Collections.singletonList("-Xmx1024M");
diff --git a/android/jps-plugin/src/org/jetbrains/jps/android/builder/AndroidDexBuildTarget.java b/android/jps-plugin/src/org/jetbrains/jps/android/builder/AndroidDexBuildTarget.java
index 685ca18..509ae65 100644
--- a/android/jps-plugin/src/org/jetbrains/jps/android/builder/AndroidDexBuildTarget.java
+++ b/android/jps-plugin/src/org/jetbrains/jps/android/builder/AndroidDexBuildTarget.java
@@ -48,6 +48,7 @@ public class AndroidDexBuildTarget extends AndroidBuildTarget {
out.println(c.isOptimize());
out.println(c.isForceJumbo());
out.println(c.isCoreLibrary());
+ out.println(c.isMultiDex());
out.println(c.getProguardVmOptions());
}
}
diff --git a/android/jps-plugin/src/org/jetbrains/jps/android/model/JpsAndroidDexCompilerConfiguration.java b/android/jps-plugin/src/org/jetbrains/jps/android/model/JpsAndroidDexCompilerConfiguration.java
index e12f3d6..1142fc8 100644
--- a/android/jps-plugin/src/org/jetbrains/jps/android/model/JpsAndroidDexCompilerConfiguration.java
+++ b/android/jps-plugin/src/org/jetbrains/jps/android/model/JpsAndroidDexCompilerConfiguration.java
@@ -26,6 +26,10 @@ public interface JpsAndroidDexCompilerConfiguration extends JpsElement {
void setCoreLibrary(boolean value);
+ boolean isMultiDex();
+
+ void setMultiDex(boolean value);
+
String getProguardVmOptions();
void setProguardVmOptions(String value);
diff --git a/android/jps-plugin/src/org/jetbrains/jps/android/model/impl/JpsAndroidDexCompilerConfigurationImpl.java b/android/jps-plugin/src/org/jetbrains/jps/android/model/impl/JpsAndroidDexCompilerConfigurationImpl.java
index 60afac0..7ca37bd 100644
--- a/android/jps-plugin/src/org/jetbrains/jps/android/model/impl/JpsAndroidDexCompilerConfigurationImpl.java
+++ b/android/jps-plugin/src/org/jetbrains/jps/android/model/impl/JpsAndroidDexCompilerConfigurationImpl.java
@@ -26,6 +26,7 @@ public class JpsAndroidDexCompilerConfigurationImpl extends JpsElementBase<JpsAn
myState.VM_OPTIONS = state.VM_OPTIONS;
myState.FORCE_JUMBO = state.FORCE_JUMBO;
myState.CORE_LIBRARY = state.CORE_LIBRARY;
+ myState.MULTI_DEX = state.MULTI_DEX;
myState.PROGUARD_VM_OPTIONS = state.PROGUARD_VM_OPTIONS;
}
@@ -95,6 +96,19 @@ public class JpsAndroidDexCompilerConfigurationImpl extends JpsElementBase<JpsAn
}
@Override
+ public boolean isMultiDex() {
+ return myState.MULTI_DEX;
+ }
+
+ @Override
+ public void setMultiDex(boolean value) {
+ if (myState.MULTI_DEX != value) {
+ myState.MULTI_DEX = value;
+ fireElementChanged();
+ }
+ }
+
+ @Override
public String getProguardVmOptions() {
return myState.PROGUARD_VM_OPTIONS;
}
@@ -120,6 +134,7 @@ public class JpsAndroidDexCompilerConfigurationImpl extends JpsElementBase<JpsAn
setOptimize(modified.isOptimize());
setForceJumbo(modified.isForceJumbo());
setCoreLibrary(modified.isCoreLibrary());
+ setMultiDex(modified.isMultiDex());
setProguardVmOptions(modified.getProguardVmOptions());
}
@@ -135,5 +150,6 @@ public class JpsAndroidDexCompilerConfigurationImpl extends JpsElementBase<JpsAn
public boolean OPTIMIZE = true;
public boolean FORCE_JUMBO = false;
public boolean CORE_LIBRARY = false;
+ public boolean MULTI_DEX = false;
}
}
diff --git a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java
index ad4143b..d6bc05d 100644
--- a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java
+++ b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java
@@ -35,6 +35,7 @@ public class AndroidDexCompilerConfiguration implements PersistentStateComponent
public boolean OPTIMIZE = true;
public boolean FORCE_JUMBO = false;
public boolean CORE_LIBRARY = false;
+ public boolean MULTI_DEX = false;
public String PROGUARD_VM_OPTIONS = "";
@Override
diff --git a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form
index c1b2689..764bce3 100644
--- a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form
+++ b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form
@@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
- <grid id="23587" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="23587" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -73,12 +73,20 @@
</component>
<component id="4b4ef" class="com.intellij.ui.components.JBCheckBox" binding="myCoreLibraryCheckBox">
<constraints>
- <grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Add &quot;--&amp;core-library&quot; flag"/>
</properties>
</component>
+ <component id="4b8ef" class="com.intellij.ui.components.JBCheckBox" binding="myMultiDexCheckBox">
+ <constraints>
+ <grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Enable multi-dex mode"/>
+ </properties>
+ </component>
</children>
</grid>
<vspacer id="e6619">
diff --git a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.java b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.java
index d323c87..ff56afb 100644
--- a/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.java
+++ b/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.java
@@ -40,6 +40,7 @@ public class AndroidDexCompilerSettingsConfigurable implements SearchableConfigu
private JBCheckBox myOptimizeCheckBox;
private JBCheckBox myJumboModeCheckBox;
private JBCheckBox myCoreLibraryCheckBox;
+ private JBCheckBox myMultiDexCheckBox;
private RawCommandLineEditor myProguardVmOptionsEditor;
public AndroidDexCompilerSettingsConfigurable(Project project) {
@@ -73,6 +74,7 @@ public class AndroidDexCompilerSettingsConfigurable implements SearchableConfigu
myOptimizeCheckBox.isSelected() != myConfig.OPTIMIZE ||
myJumboModeCheckBox.isSelected() != myConfig.FORCE_JUMBO ||
myCoreLibraryCheckBox.isSelected() != myConfig.CORE_LIBRARY ||
+ myMultiDexCheckBox.isSelected() != myConfig.MULTI_DEX ||
!myProguardVmOptionsEditor.getText().equals(myConfig.PROGUARD_VM_OPTIONS);
}
@@ -83,6 +85,7 @@ public class AndroidDexCompilerSettingsConfigurable implements SearchableConfigu
myConfig.OPTIMIZE = myOptimizeCheckBox.isSelected();
myConfig.FORCE_JUMBO = myJumboModeCheckBox.isSelected();
myConfig.CORE_LIBRARY = myCoreLibraryCheckBox.isSelected();
+ myConfig.MULTI_DEX = myMultiDexCheckBox.isSelected();
myConfig.PROGUARD_VM_OPTIONS = myProguardVmOptionsEditor.getText();
}
@@ -93,6 +96,7 @@ public class AndroidDexCompilerSettingsConfigurable implements SearchableConfigu
myOptimizeCheckBox.setSelected(myConfig.OPTIMIZE);
myJumboModeCheckBox.setSelected(myConfig.FORCE_JUMBO);
myCoreLibraryCheckBox.setSelected(myConfig.CORE_LIBRARY);
+ myMultiDexCheckBox.setSelected(myConfig.MULTI_DEX);
myProguardVmOptionsEditor.setText(myConfig.PROGUARD_VM_OPTIONS);
}
--
1.9.3 (Apple Git-50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment