Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between android.enableD8.desugaring in Android Studio 3.1 and android.enableD8

In Android Studio 3.0 there is an option android.enableD8 to enable D8 (Next-generation Dex Compiler). In Android Studio 3.1 a new option was added for this like android.enableD8.desugaring as per their updates.

What actually does android.enableD8.desugaring do in Android Studio 3.1 and what's the difference compared to the android.enableD8 option?

like image 669
0xAliHn Avatar asked Mar 28 '18 14:03

0xAliHn


People also ask

What is Desugaring in Android?

The desugaring process rewrites your app's code to instead use this library at runtime. To enable support for these language APIs on any version of the Android platform, update the Android plugin to 4.0.0 (or higher) and include the following in your app module's build.gradle file: android {

What is D8 and R8?

D8: a next-generation DEX compiler The implications being that D8 could compile to DEX in 30% less time and produce smaller DEX files than DX. D8 also implements “desugaring”, so it can accept Java 8 code as input by default. As an extension to D8, R8 is a Java code shrinker built as a replacement for ProGuard.


1 Answers

The desugar step is executed normally after javac to optimize the bytecode. Enabling desugaring in D8 will remove that step entirely, and execute desugar as part of D8, making it faster and more optimized.

Source: https://android-developers.googleblog.com/2017/08/next-generation-dex-compiler-now-in.html

like image 174
WoogieNoogie Avatar answered Oct 28 '22 03:10

WoogieNoogie