BT

Android Studio Switched to New D8 Compiler

| by Sergio De Simone Follow 14 Followers on Apr 09, 2018. Estimated reading time: 2 minutes |

Recently released Android Studio 3.1 switched to a new DEX compiler which promises to provide better and faster compilation, writes Google software engineer Jeffrey van Gogh. Compared to the previous compiler, called DX, D8 compiles faster and outputs smaller DEX files, all while having the same or better app runtime performance.

The conversion of .class bytecode into .dex bytecode for the Android Runtime is an essential step when building an app for Android, and the process directly impacts the overall build time and app performance. Using its own benchmark project, Google has observed both faster compilation times (by a 20% factor) and smaller .dex file sizes (although by just a few percent). However, these results should be taken with a pinch of salt, as they are based on a single benchmark. A few users have actually reported slower compilation times when using D8 from Android Studio 3.0.

Among the other advantages of using D8 is its support for desugaring, which makes it possible to translate into Java 7 features that are only available in Java 8, such as lambdas. Integrating the desugaring step into D8 impacts all developers of tools that read or write .class bytecode, since it will use the Java 8 format. You can revert to the previous behaviour, where desugaring happened just after the Java compilation and .class bytecode followed the Java 7 format, by setting a property in your gradle file:

android.enableD8.desugaring=true

Should you experience any general issue with D8, you can revert to DX changing a setting in your gradle.properties file, as shown below:

android.enableD8=false

The fact that D8 is now the default compiler in Android Studio does not mean developers have to rush to migrate their apps. Indeed, the old DX compiler will remain available until Google has gathered enough confidence that D8 cannot cause any regressions for users. This means Google will continue to fix bugs found in DX for at least six months. During this first phase, Google engineers will carefully monitor the D8 bug tracker to find any issues that could be a showstopper in the migration plan. After six months free of major regressions, Google will keep DX available for at least one year, in order to ensure that any development team gets plenty of time to migrate. After that, DX will only be available through a legacy version of Android Studio.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT