Mithun Sarker
Mithun Sarker

Reputation: 4023

How to load native library conditionally based on CPU architecture in android

In my app I am using a set of native library .And those library are available for different CPU architecture. But the problem is all those library are taking almost 87% of the apk size .

enter image description here

enter image description here

I want to reduce apk size for downloading, hence I want make conditional apk based of CPU architecture. How can I do it ?

Upvotes: 1

Views: 362

Answers (1)

Okas
Okas

Reputation: 2664

Use AbiSplitOptions.

Example:

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

Upvotes: 2

Related Questions