Search code examples
androidflutterarmapkabi

Flutter large apk size and releasing for different ABIs


I am trying to build a release app with low file size in Flutter. Yesterday the release apk size was around 16mb, but after I updated the flutter, the size goes to 23mb.

After some researching, I fount out that flutter generates app bundle with all of the ABIs in it and after the update, new API has been added to apk.

After adding app to android studio apk analyzer, I can see the different ABIs in them as below:

x86_64          7.1mb
arm64-v8a       7mb
armeabi-v7a     6.8mb

I can use flutter build apk --split-per-abi to generate apks for different ABIs. Now the question is, can a arm64-v8a system run x86_64 apk? (or the otherwise). Or can any of these ABI apk releases, be run in all the devices?

I don't release my app on app stores, I just put it on my clients website and their clients will download it from there (or it will be sent to them by email, ... ). So I need one release that works in all of the android devices and the full bundle release is way too large (23mb).

EDIT: I just tested x86_64 build on a arm64-v8a device and it did not install. but the armeabi-v7a version did install.


Solution

  • I did some research and tried the release versions on different devices and this is the result: The command is : flutter build apk --split-per-abi

    • The x86_64 apk version does not work on any other devices. I could not find an x86_64 device but I assume it will work on x86_64 devices!
    • The arm64-v8a apk version gets installed on arm64-v8a but it will not install on armeabi-v7a devices. (armeabi-v7a is older than arm64-v8a).
    • armeabi-v7a apk version works on armeabi-v7a and arm64-v8a devices. I did not find an x86_64 device but I think it will work on this device too.

    Summary: The newer version of the ABI can run the older apk builds. The order is: armeabi-v7a then arm64-v8a then x86_64.

    For example, armeabi-v7a will install and work on all of the devices and if you build and arm64-v8a apk, it will NOT install on armeabi-v7a devices.

    There are other architectures that are no longer used (mips, mips64, armeabi) and Flutter by default, will not contain them in builds.

    the X86 and X86_64 architectures are for very limited number of devices, but may be useful for debugging in the emulator.

    This was the result of my researches and testings. I decided to only use the armeabi-v7a so the apk size will be 8mb instead of 23mb.

    If someone else having this question/trouble, I hope this helps :).