我在我的项目中使用 ffmpeg 库。问题是应用程序 apk 大小太大。有人知道如何减小 apk 大小吗?
任何帮助、建议或链接将不胜感激。谢谢。
你好@tech_android 和@gulab patel。我已经找到了解决方案。
Android Gradle 允许您根据处理器(“armeabi-v7a”、“arm64-v8a”、“x86”和“x86_64”)拆分 apk。这样你最终会得到 4 个 apk,而不是一个,每个的大小将是第四部分,在 Google Play 中,你上传所有四个 apk,当用户尝试下载你的应用时,Google Play 会选择正确的 apk取决于用户的设备处理器。
您必须以这种方式在 gradle 中设置应用程序拆分:
在compilerOptions节点下方(在android json节点内):
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 x86_64.
// 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 "armeabi-v7a"
include "arm64-v8a"
include "x86"
include "x86_64"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
就在依赖节点之前:
// This next piece of code is used by apk Split
// map for the version code that gives each ABI a value. make sure to list all ABIs mentioned in splits block, an keep the order.
ext.versionCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)