Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm adding extra size to my apk

Tags:

android

realm

The initial size of my apk was 2.3 MB before adding Realm library, after adding the same, the apk size increased to 10.61 MB, is it possible to reduce the size, if yes how? if not then please recommend an alternate to Realm

like image 439
Gurleen Sethi Avatar asked Dec 18 '16 01:12

Gurleen Sethi


People also ask

What is the difference between APK size and download size?

Raw File Size represents the unzipped size of the entity on disk while Download Size represents the estimated compressed size of the entity as it would be delivered by Google Play. The % of Total Download Size indicates the percentage of the APK's total download size the entity represents.


1 Answers

You can use abi splits to reduce size of APK.

Normally (without splits) it includes files to support almost all architectures (ARM7, ARMv7, ARM64, x86, MIPS) This is why it's too big.

With abi splits, android studio will generate APK for each architecture, and each APK will not include files for any other architecture

Just add below section in gradle file. Also check this realm documentation

splits {
    abi {
        enable true
        reset()
        include 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'x86', 'x86_64'
    }
}

Important

Each distrubtion(APK) will only work on appropriate device. So we can say, app-x86_64-release.apk will not work on armeabi-v7a architectured device. If you try, you'll face Failure [INSTALL_FAILED_NO_MATCHING_ABIS] error.

You can also check these documentations.

  • Multiple APK Support
  • Configure APK Splits
like image 104
blackkara Avatar answered Oct 10 '22 22:10

blackkara