Exclude jniLibs folder from Production APK

2019-05-05 18:10发布

My app has a dev and production flavor defined in Gradle. In my production flavor, I would like the resulting APK file to NOT have my x86 jniLibs binaries. I only use them for testing in genymotion, and some of them are large so I really need the space.

The only way I can get this to kinda work is by manually deleting my src/main/jniLibs/x86 folder then building, but I then have to do this every time I build, and then restore the libs later. Is there a simpler way using gradle/proguard/something?

2条回答
我想做一个坏孩纸
2楼-- · 2019-05-05 18:51

Move the lib from app/src/main/jniLibs/x86 to app/src/debug/jniLibs/x86

查看更多
祖国的老花朵
3楼-- · 2019-05-05 18:52

Here is the configuration to exclude x86 SO file for RELEASE build variant:

android {
    buildTypes {
        release {
            ndk {
                abiFilters "armeabi-v7a", "armeabi" // includes ARM SO files only, so no x86 SO file
            }
        }
    }
}

And, there is x86 SO in the "debug" build variant output since no filter is set.

查看更多
登录 后发表回答