4

D8 is a command line tool that Android Studio and the Android Gradle Plugin use to compile project's Java bytecode into DEX bytecode. This command has several options :

--output path, --file-per-class, --no-desugaring, --main-dex-list etc.

I have several questions:

  1. How to pass this flags to d8 from gradle build file?
  2. How to view full d8 command (with all flags) which Android Studio actualy use when it builds apk.

I already tried to use DexOptions command with additionalParameters property.

android {
    ....
    dexOptions {
        additionalParameters = ['--main-dex-list=mylist.txt']
    }
}

But it looks like it doesn't work.

Before D8 tool there was DX tool. Params can be sent to DX like this: enter image description here But now this doesn't work. Probably because of now D8 dexing task name doesn't starts with dex word.

I also noticed that there is property android.enableD8.desugaring=true which can be declared in gradle.properties file. I assume that this property turns on --no-desugaring flag of D8.

If so maybe other properties also can be set throught gradle.properties file? Is there a documentation of all available android.enableD8.* properties ?

UPDATE:

There is multiDexKeepFile property which can be declared in each BuildType block. It looks like this property does exactly what --main-dex-list flag of D8 does. Ok, but what about other flags?

ashakirov
  • 12,112
  • 6
  • 40
  • 40

0 Answers0