Android Studio Gradle Plugin 3.4.1 update

The new Android Gradle plugin comes to a minor change and some updates for the version code to 3.4.1. Here are some behavior changes you should know.

R8 enabled by default. You can see the old way we use before as followed:

Old compile flow

As you can see, a java file would be compiled into .class file and be applied the ProGuard rules to confuse the code. After that, Gradle would use the D8 and desugaring the .class file to .dex file.

Here is the new flow:

New compile flow

New Gradle plugin merges two steps (ProGuard and D8/Desugar) into one step - R8. That means you would spend less time compiling the project.

R8 is designed to work with the exiting ProGuard rules. So, you don’t have to take any further actions to benefit from R8. But if you experience any issues by using R8, you can disable it.


# Disables R8 for Android Library modules only.
android.enableR8.libraries = false
# Disables R8 for all modules.
android.enableR8 = false
ndkCompile is deprecated.

It seems that Google wants you to use CMake to compile the NDK files. You can’t use ndkBuild - the compile your native libraries. I used to use that so many places in old projects. Now I need to use CMake instead.