Exclude native libraries from debug APK and dependencies


(AndreKR) #1

I added a Maven dependency that comes with native libraries to the build.gradle of my Android project. Now I would like to exclude those jniLibs from the debug APK (but keep them in the release APK).

There seem to be two problems:

  1. sourceSets seem to only add, not overwrite.
    As an experiment I added a new resource folder to my project. I was able to use this folder using android.sourceSets.release.res.srcDir = 'new-folder', but the original res folder was still also included.
    In my own project I just moved the jniLibs to a separate folder and then only included that for release builds, but this technique doesn’t work for the dependencies.

  2. I have no idea how to influence the gradle file of the dependency from the gradle file of the main project.