领域为我的apk增加了额外的大小 [英] Realm adding extra size to my apk

查看:70
本文介绍了领域为我的apk增加了额外的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在添加Realm库之前,我的apk的初始大小为2.3 MB,在添加相同库之后,apk的大小增加至10.61 MB,是否可以减小大小,如果可以,怎么办?如果没有,请推荐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

推荐答案

您可以使用abi拆分来减小APK的大小.

You can use abi splits to reduce size of APK.

通常(不包括拆分)中它包含支持几乎所有体系结构(ARM7,ARMv7,ARM64,x86,MIPS)的文件,这就是为什么它太大的原因.

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

使用abi拆分,android studio将为每种架构生成APK,并且每个APK均不包含任何其他架构的文件

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

只需在gradle文件中的以下部分添加.还要检查此领域文档

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'
    }
}

重要

每个干扰(APK)仅在适当的设备上起作用.因此,可以说app-x86_64-release.apkarmeabi-v7a体系结构的设备上将不起作用.如果尝试,将遇到Failure [INSTALL_FAILED_NO_MATCHING_ABIS]错误.

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

这篇关于领域为我的apk增加了额外的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆