2017-07-09 12 views
1

在我的应用程序中,我使用了一组本机库。并且这些库可用于不同的CPU架构。但问题是,所有这些库正在采取几乎87%的apk大小。如何在基于CPU架构的条件下加载本地库在Android中

enter image description here

enter image description here

我想,以减少大小APK下载,所以我想使基于CPU架构的条件APK。我该怎么做 ?

+1

据我所知,你应该在你的应用程序中每个'cpu'创建不同的'flavour'并使用所需的库每个'flavour'。这会给你更多的输出apk文件。 – Merka

回答

2

使用AbiSplitOptions

例子:

android { 
    ... 
    splits { 

    // Configures multiple APKs based on ABI. 
    abi { 

    // Enables building multiple APKs. 
    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. 
    reset() 

    // Specifies a list of ABIs that Gradle should create APKs for. 
    include "x86", "armeabi-v7a", "mips" 

    // Specify that we want to also generate a universal APK that includes all ABIs. 
    universalApk true 
    } 
    } 
} 
+2

如果您在Google Play商店中发布APK,请注意每个拆分的** versionCode **。幸运的是,在官方网站上,这很好[https://developer.android.com/studio/build/configure-apk-splits.html#configure-APK-versions]。 –

相关问题