Controlling APK Size When Using Native Libraries

Image for post
Image for post

What is ABI and how it works?

mips, mips64, X86, X86–64, arm64-v8a, armeabi, armeabi-v7a

Let’s take an example to understand ABI in detail

Image for post
Image for post
Analysis of the APK file
Image for post
Image for post
APK details after adding Realm

APK size is now 5MB from 74KB and we all are like …

Let’s take a look what happened there.

Image for post
Image for post
Realm distribution for different CPU architecture

Let’s see how ABI split can help us in avoiding this problem

Android application level build.gradle file.
Image for post
Image for post
Multiple APK files generated after enabling split

Amazing right! We went from 74KB to 5MB and came back to 1.3 MB.

But But But….

There is even a bigger problem than this cumbersome maintenance.

Discussion about the APK side loading

It’s time to find a solution

build.gradle file with abiFilters configuration
Image for post
Image for post
APK with “armeabi-v7a” and “x86” libs

TL;DR

Image for post
Image for post
Detail about CPU Architecture
Image for post
Image for post

Detail explanation about each architecture

armeabi, armeabi-v7a, and arm64-v8a

armeabi

armeabi-v7a

arm64-v8a

X86

X86–64

mips and mips64

Image for post
Image for post
Google Play Console warning when uploading application with ABI filters

References

Android Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store