I want to use the recently introduced D8 compiler from Google to build a dex file. Unfortunately, I didn't find the jar executable in the build-tools folder (like the dx tool). Does anyone know where it's located instead?
Thanks in advance.
I want to use the recently introduced D8 compiler from Google to build a dex file. Unfortunately, I didn't find the jar executable in the build-tools folder (like the dx tool). Does anyone know where it's located instead?
Thanks in advance.
There is no D8.jar anywhere in build-tools. D8 is distributed as a maven artifact instead. It can be downloaded from https://maven.google.com. The artifact is named com.android.tools:r8
because D8 is a part of the R8 project. The jar contains both R8 and D8 commandline interfaces, so, in theory, it can be downloaded and used from a commandline like:
java -cp r8.jar:<...dependency jars> com.android.tools.r8.D8 <D8 arguments here>
java -cp r8.jar:<...dependency jars> com.android.tools.r8.R8 <R8 arguments here>
However this artifact jar has a lot of dependencies and if you want to use it outside of the gradle-based build then it is easier to build r8/d8.jar executable jars from the sources by yourself. The instruction how to do it is at https://r8.googlesource.com/r8/. The resulting jars are self-contained (all deps bundled in).
The Android Gradle plugin (and, therefore, Android Studio) doesn't depend on the com.android.tools:r8
. R8/D8 classes are bundled into com.android.tools.build:builder
(one of the libraries that gradle plugin consists of) instead.
D8 dexer has become the default compiler in @AndroidStudio 3.1
Expect faster and smarter app compilation
Faster, smarter app compilation is always a goal for the Android tools teams. That's why we previously announced D8, a next-generation dex compiler. D8 runs faster and produces smaller .dex files with equivalent or better runtime performance when compared to the historic compiler - DX
Please see comparition beetween DX vs D8 :
You can always revert to DX for now via this setting in your project's gradle.properties file:
android.enableD8=false