Home United States USA — software Android Studio Switched to New D8 Compiler

Android Studio Switched to New D8 Compiler

315
0
SHARE

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.
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.
In addition to being faster, the new compiler, called D8, is tout to produce equivalent or better runtime performance in comparison to the previous compiler, DX.
The conversion of .class bytecode into .dex bytecode for the Android Runtime is an essential step when building an app for Android and directly impacts the overall build time and app performance. Using its own benchmark project, Google has measured both faster compilation times, by a 20% factor, and smaller.dex file sizes, by just a few percents though. These results should be taken with a grain of salt, since 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:
Should you experience any general issue with D8, you can revert to DX changing a setting in your gradle.properties file, as shown below:
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 any 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 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, to ensure that any development team out there gets plenty of times to migrate. After that, DX will only be available through a legacy version of Android Studio.

Continue reading...