This plugin will help you exclude so files by flavor or buildType
-
Add the following scripts to your build.gradle
buildscript { repositories { jcenter() maven { // package is not in jcenter for now url "http://dl.bintray.com/jween/maven" } } dependencies { classpath 'com.jween.gradle:android-soexcluder:1.0' } } apply plugin: 'com.android.application' apply plugin: 'android-soexcluder'
Note: You MUST apply android-soexcluder AFTER android application plugin
-
Wish we have step 2!
But that's it, it a quite simple small tool to deal with so files.
-
Exclude specific so files by flavors
soexcluder { // exclude armeabi-v7a/foo.so and armeabi-v8a/bar.so for flavor1 flavor1 { exclude "lib/armeabi-v7a/foo.so", "lib/armeabi-v8a/bar.so" } // Reserve only v7a so files except foo.so for debug buildType debug { include "lib/armeabi-v7a/*.so" exclude "lib/armeabi-v7a/foo.so" } }
-
Exact the same path pattern as gradle include/exclude api
soexcluder { // Reserve all so files for debug buildType except foo.so debug { include "**/*" exclude "**/foo.so" } }
-
You can even use regex in flavor/buildType entry!
soexcluder { // Remove all so files if the flavor or buildType name ends with 'o' ".*o" { exclude "**/*" } }
"THE BEER-WARE LICENSE" (Revision 42):
<Jween.Lau@gmail.com> wrote this file. As long as you retain this notice
you can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return. -Jween Lau