【问题标题】:Not able to Reduce Android APK size using Splits无法使用拆分减少 Android APK 大小
【发布时间】:2018-02-23 10:31:18
【问题描述】:

我在我的应用程序中使用https://github.com/WritingMinds/ffmpeg-android 库。 我发现 Apk 大小约为 20mb,它包含 ABI(x86 和 armeabi-v7a)中的资产,使用 Android Studio 中的 apk 分析器。find screenshot here

所以为了修复它,我使用了developer.android.com中提到的拆分

android {...
 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, armeabi-v7a, and mips.

    // 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 "x86", "armeabi-v7a", "mips"

    // Specifies that we do not want to also generate a universal Apk that includes all ABIs.
    universalApk false
    }
  }
}

它为每个 ABI 生成两个 Apk,但它并没有减少我使用 Apk 分析器检查的应用程序大小,并且它仍然拥有两个 ABI 的资产。

【问题讨论】:

  • 更好的方法是使用静态ffmpeg库而不是共享,因为共享库放在apk中,如果你使用静态库,库的部分使用代码被编译成apk的.so跨度>

标签: android apk android-ffmpeg


【解决方案1】:

可能不是最好的解决方案,但至少需要考虑一些问题。您可以排除 x86 和 mips 架构的所有库,因为目前市场上没有 mips 设备,而 x86 设备通过 Intel Houdini 库很好地支持 armeabi-v7a 代码 - 这将显着减小大小。

对于拆分问题 - 似乎是 Android Studio 中的一个错误,因为代码与 Google Android Docs 中的代码完全相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    • 2014-09-25
    • 2017-03-02
    • 2021-08-03
    • 1970-01-01
    相关资源
    最近更新 更多