Difference between D8 and R8 android

0xAliHn picture 0xAliHn · Mar 29, 2018 · Viewed 12k times · Source

As android studio introduced two new tools D8 and R8. As per google documentation D8 is a dex tool and R8 is a progourd tool but as their explanation both are doing almost same thing like below:

D8 is a dexer that converts java byte code to dex code.

R8 is a java program shrinking and minification tool that converts java byte code to optimized dex code.

It seems both converts java byte code to dex code literally. So, Whats actually they are doing internally in case of converting dex code?

Answer

Dreamer picture Dreamer · Apr 8, 2018

D8 dexer and R8 shrinker

D8->D8 is a dexer that converts java byte code to dex code.

R8->R8 is a java program shrinking and minification tool that converts java byte code to optimized dex code.

Android developers know that dex compilation is a key step in building an APK. This is the process of transforming .class bytecode into .dex bytecode for the Android Runtime (or Dalvik, for older versions of Android). The dex compiler mostly works under the hood in your day-to-day app development, but it directly impacts your app's build time, .dex file size, and runtime performance.

The R8 project uses depot_tools from the chromium project to manage dependencies. Install depot_tools and add it to your path before proceeding.

The R8 project uses Java 8 language features and requires a Java 8 compiler and runtime system.

  • New version number scheme following the SDK Tools revision number.
  • Support for true debug build. No need to change the value of debuggable in the Android Manifest.

    Incremental build will automatically insert debuggable==true while using the "export signed/unsigned application package" will not. If debuggable=true is set, then release builds will actually do a debug build.

  • Automatic Proguard support in release builds. Only need to have a proguard.config

    property in default.properties that points to a proguard config file.

  • Completely rewritten Visual Layout Editor. This is very much a work in progress.

    • full drag and drop from palette to layout for all Layout classes.
    • Move widgets inside a Layout view, from one Layout view to another and from one layout file to another.

    • Contextual menu with enum/flag type properties.

    • New zoom controls.