Android application are typically written in languages that compile to Java class files. The officially supported languages for Android development are Java and Kotlin (and C/C++). However, the Android Runtime (Art) does not execute Java class files, it executes dex files. Therefore, when compiling for Android an extra compiler, called a dexer, is needed to translate class files to dex files.
Java and Kotlin applications typically bundle all class files for all libraries in a zip file with the user code. If you use large libraries, the size of such bundled applications can become very large. That is typically OK for server-side code, but when building applications for small Android devices, this is unfortunate. Therefore, application shrinking is very important in the Android ecosystem. The goal of application shrinking is to reduce the size of applications by removing all classes, methods, and fields that are not used by the application or that can be optimized away. This is complicated by heavy use of reflection in the Android eco-system.
In this talk, I’ll introduce you to the D8 dexer and the R8 application shrinker built by my team at Google with the goal of producing smaller Android applications and reducing compilation time.