Created
May 7, 2014 03:21
-
-
Save creativepsyco/57a232d3a2e2c90195f0 to your computer and use it in GitHub Desktop.
Gist for creating Dex file for class files in Android Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The Task Below uses the Dex Tool to create classes.dex file for the archive | |
* This dex file can be then be loaded at runtime to prevent the 64K Dalvik Method Limit | |
*/ | |
import org.apache.tools.ant.taskdefs.condition.Os | |
android.libraryVariants.all { variant -> | |
def name = variant.buildType.name | |
if (name.equals(com.android.builder.BuilderConstants.DEBUG)) { | |
return; // Skip debug builds. | |
} | |
log.info("========================================") | |
log.info("Starting Variant Build") | |
log.info("Variant Name: ${variant.name}") | |
log.info("Build Type Name: ${variant.buildType}") | |
log.info("Variant: ${variant}") | |
log.info("========================================") | |
String cmdExt = Os.isFamily(Os.FAMILY_WINDOWS) ? '.bat' : '' | |
def task = project.tasks.create ("dex${name.capitalize()}", Exec) | |
task.dependsOn variant.javaCompile | |
task.commandLine "${System.env.ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}/dx${cmdExt}", '--dex', | |
"--output=${buildDir}/classes/${variant.name}/classes.dex", | |
"${buildDir}/classes/${variant.name}" | |
// Make sure we run our Dexing task before the packageReleaseJar Task | |
Task packageJar = project.tasks.getByName("package${name.capitalize()}Jar") | |
packageJar.dependsOn(task) | |
} |
Dear Sir
when new gradle version
we have new API -- Transform
i search. gradle system -- https://android.googlesource.com/platform/tools/base/+/refs/tags/gradle_3.4.0
when Android build default use Transform with DexArchiveBuilderTask. &. DexArchiveBuilder
those can create. dex file (. class file --> dex file. /. class folder --> dex file)
how use those or create the same to. trans myself class folder to dex file ?
THX
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You would need to declare the
BUILD_TOOLS_VERSION
string in your build file.