Search code examples
androidandroid-studiogradleandroid-gradle-pluginapk

How to setup compression for APK with Gradle 6.1.1?


In my project (Android, Kotlin, Android Studio) I am using Gradle 5.6.4 and Gradle Plugin 3.5.3. With it size of release APK is 32 MB.

After update to Gradle 6.1.1 and Gradle Plugin 4.0.0 the size of release APK is increased to 57 MB.

As I know Google Play should additionally compressed APK for users but this is not comfortable for our QA and CI processes.

I've analyzed both APKs and found that the compression level is higher with old Gradle (46% against 84%). And there is no other differences.

Is there some way to improve compression for new Gradle?


Solution

  • Since AGP 3.6.0, native package libraries are packaged uncompressed by default. That is why the increase in size. Though the upload size is larger because of this, there are some benefits for the user.

    If you instead want to package compressed native libraries, add this to your manifest:

    <application
        android:extractNativeLibs="true"
        ... >
    </application>
    

    Reference: https://developer.android.com/studio/releases/gradle-plugin#extractNativeLibs