langerhans
langerhans

Reputation: 779

Exclude native library in Gradle Android build

Contrary to many other posts on this topic, I want to exclude a native library from an Android build with Gradle.

libfoo.so resides in a library project in the default directory thelib/src/main/jniLibs. In my main project's build.gradle I try to exlude the file as follows:

sourceSets {
    all{
        jniLibs {
            exclude '**/libfoo.so'
        }
    }
}

This does not work though, the file is still in the final APK. I tried different path specifications already, but none of them work.

Is this even possible, or is there a workaround?

Upvotes: 8

Views: 4645

Answers (1)

user3689913
user3689913

Reputation: 392

I know this is an old question, i solved my problem with the following

packagingOptions {
 exclude 'lib/arm64-v8a/libfoo.so'
}

Hope it helps someones...

Note: On further searching someone had already solved a similar issue; Gradle exclude arm64 libs

Upvotes: 8

Related Questions