5

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.

False
  • 101
  • 1
  • 10
  • If you are using Android Studio Canary 3.1, it should be the default compiler as per: https://androidstudio.googleblog.com/2017/10/android-studio-31-canary-1-now-available.html – Morrison Chang Feb 13 '18 at 22:27

2 Answers2

2

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.

Darth Beleg
  • 2,657
  • 24
  • 26
-3

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 : enter image description here

You can always revert to DX for now via this setting in your project's gradle.properties file:

android.enableD8=false
Dhaval Jivani
  • 9,467
  • 2
  • 48
  • 42
  • 1
    This doesn't seems answer the question, the OP is asking for "file path" of d8.jar in Android Studio. – 林果皞 Apr 27 '18 at 20:38