13

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

Viktor K
  • 2,153
  • 3
  • 25
  • 40

1 Answers1

11

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.

Vlad
  • 18,195
  • 4
  • 41
  • 71
  • currently ndk {} section is deprecated. Do you now another way to use it ? – Vetalll Aug 11 '16 at 15:21
  • This can be done without using product flavors too, you just add the ndk section into your debug or release section as necessary. See here http://stackoverflow.com/questions/30946365/how-to-import-only-selected-native-library-abis-from-aar – sham Dec 25 '16 at 02:03
  • @Vetalll you can use android.useDeprecatedNdk=true in gradle.properties. However, i am not sure – Shubham AgaRwal Mar 09 '18 at 09:19