Skip to content

Reduce APK File Size

Brianvdb edited this page Dec 13, 2017 · 3 revisions

There are a few ways to reduce your APK file size.

Configure multiple APKs for ABIs

You can build multiple APKs for each architecture.

android {
    ...
    splits {

        // Configures multiple APKs based on ABI.
        abi {
            // Enables building multiple APKs per ABI.
            enable true

            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for x86 and armeabi-v7a.
            // Resets the list of ABIs that Gradle should create APKs for to none.
            reset()

            // Specifies a list of ABIs that Gradle should create APKs for.
            include "x86", "armeabi-v7a"

            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }
}

Exclude FFprobe

If you do not use FFprobe in your project it is recommended that you remove the FFprobe library files from your APK build. To do this, add the following packagingOptions block in your app module Gradle.

android {
    ...
    packagingOptions {
        exclude 'lib/armeabi-v7a/ffprobe.so'
        exclude 'lib/x86/ffprobe.so'
    }
}

Exclude FFmpeg

Similarly, you should exclude FFmpeg library files if you only use FFprobe in your project. To do this, add the following packagingOptions block in your app module Gradle.

android {
    ...
    packagingOptions {
        exclude 'lib/armeabi-v7a/ffmpeg.so'
        exclude 'lib/x86/ffmpeg.so'
    }
}
Clone this wiki locally