packaging options based on product flavor in gradle

I m using packaging options to exclude some libs. Is it possible to have packaging options based on product flavor. For example -

android {
    productFlavors {
        flavorDimensions 'models'
            S2 {
                flavorDimension 'models'
                minSdkVersion 22
                ....
            }
            S6 {
                flavorDimension 'models'
                minsdkversion 22
                ....
            }
        }


    packagingOptions {
        exclude 'lib/armeabi/libs2.so'
        exclude 'lib/arm64-v8a/libs6.so
    }
}

Now in above code, I want to exclude only 'lib/armeabi/libs2.so' in apk generated for s6 flavor and want to exclude only 'lib/arm64-v8a/libs6.so' in apk generated for s2 flavor

How can we achieve this.

Answers


I've encountered the same issue, and then, I developed a gradle plugin to resolve this. You can check it(android-soexcluder) out here

It is super easy to use:

soexcluder {
    s2 {
        exclude 'lib/arm64-v8a/libs6.so'
    }

    s6 {
        exclude 'lib/armeabi/libs2.so'
    }
}

Beside this, there is even a sample project inside the repository


Need Your Help

Centering a background image in Android

android background orientation center

I have a background image about 100 x 100 that I want to center in an Android app. Is there a way to do this?

Cache images provided through script

c# .net asp.net iis-7 caching

I have a script, which by using several querystring variables provides an image. I am also using URL rewriting within IIS 7.5.