1

When I use Gradle to build my Android app, it executes a whole chain of Android command line build tools like 'dx' to build my apk.

Those command line tools all have 'options'. I would like to specify some of these options within my Gradle build. How is this possible?

Aureulus X
  • 111
  • 2
  • I know that I can add some predefined options like so: android { dexOptions { incremental false preDexLibraries = false jumboMode = false } } Still. I was looking to be able to define all the options tools like dx offer. – Aureulus X Sep 11 '14 at 07:12

1 Answers1

1

Check out this answer, which shows that you can use dexTask.additionalParameters to pass additional arguments to the dx tool. An easy way to get access to the dexTask is from the variants list:

android.applicationVariants.all { variant ->
    Dex dexTask = variant.dex
    if (dexTask.additionalParameters == null) dex.additionalParameters = []
    // This is just an example:
    dexTask.additionalParameters += '--help'
    // you could use others, such as '--multi-dex', or anything else that appears in the '--help' output.
}

From the source of AndroidBuilder.java, you can see which commandline arguments are already being added to the dx tool before appending your additionalParameters.

Community
  • 1
  • 1
Joe
  • 42,036
  • 13
  • 45
  • 61