Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude abi from apk

In my application I use renderscript which has native code for x86, armeabi-v7a and mips (~2.7Mb each). Also I read that the mips architecture has just a few devices. So I'd like to bundle my application in two APKs: universal (eg. x86 and armeabi-v7a) and mips. I found that split section helps to create apk for mips, but universal apk still contains mips architecture. So my question is how to exclude abi from result apk?

Thanks

like image 212
Viktor K Avatar asked Sep 01 '15 14:09

Viktor K


People also ask

What is ABI in Mobile?

Different Android devices use different CPUs, which in turn support different instruction sets. Each combination of CPU and instruction set has its own Application Binary Interface (ABI). An ABI includes the following information: The CPU instruction set (and extensions) that can be used.

What is split config APK?

SAI (Split APKs Installer) is an App that lets you install multiple APKs as if it was a single Package.

What is Armeabi?

EABI - Embedded Application Binary Interface. So ARMEABI are compiled binaries matching your android device's CPU architecture. e.g. arm64-v8a (Nexus 5x) - 64bit - ARM Cortex-A35, ARM Cortex-A53, ARM Cortex-A57, ARM Cortex-A72, ARM Cortex-A73.

What is Armeabi v7a in Android?

armeabi-v7a is the older target, for 32 bit arm cpus, almost all arm devices support this target. arm64-v8a is the more recent 64 bit target (similar to the 32-bit -> 64 bit transition in desktop computers).


1 Answers

You can try setting up another flavor that contains everything but MIPS. In the build.gradle file from one of the test projects that are part of the Android Gradle plugin sources, I found this:

apply from: "../commonHeader.gradle"
buildscript { apply from: "../commonBuildScript.gradle", to: buildscript }
apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion = rootProject.ext.buildToolsVersion
    productFlavors {
        x86 {
            ndk {
                abiFilter "x86"
            }
        }
        arm {
            ndk {
                abiFilters "armeabi-v7a", "armeabi"
            }
        }
        mips {
            ndk {
                abiFilter "mips"
            }
        }
    }
}

It looks like their arm flavor basically includes the two common ARM ABIs. You could probably define an "universal" flavor containing x86 and armeabi-v7a.

They have another test project, whose build.gradle contains:

splits {
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a', 'mips'
    }
}

You might be able to use something similar, and drop the mips from there.

like image 64
Vlad Avatar answered Oct 18 '22 20:10

Vlad