Exclude native library in Gradle Android build

Contrary to many other posts in this section, I want to exclude my own library from the Android assembly using Gradle.

libfoo.solocated in the library project in the default directory thelib/src/main/jniLibs. In my main build.gradle project, I am trying to exclude a file as follows:

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

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

Is this possible, or is there a workaround?

+4
source share
1 answer

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

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

, -...

: - ; Gradle arm64 libs

+2

Source: https://habr.com/ru/post/1583979/


All Articles