Difference between D8 and R8 android

后端 未结 3 925
孤城傲影
孤城傲影 2021-02-04 05:48

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

3条回答
  •  伪装坚强ぢ
    2021-02-04 06:39

    D8 processes each Java class file individually without looking at the entire program. This makes the conversion to DEX fast, since classes can be processed in parallel, and during development it allows fast recompilation when the code of a class is modified.

    On the other hand, R8 (like ProGuard) reads in the entire application and makes changes and optimizations (e.g. inlining) that require knowing the entire class hierarchy. For instance, R8 will remove unused classes and methods ("tree shaking") and rename classes, methods and fields (except for the application's entry points).

    In Android Studio 3.1, D8 has replaced DX as the tool that converts Java class files to DEX, but R8 has not been enabled yet.

提交回复
热议问题