Aureulus X
Aureulus X

Reputation: 111

Gradle Android build: how to specify options for the Android command line build tools used..?

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?

Upvotes: 1

Views: 826

Answers (1)

Joe
Joe

Reputation: 42155

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.

Upvotes: 1

Related Questions