My project has 3 different buildTypes and I need only one of them to keep the debug info of its native libraries. I'm using com.android.tools.build:gradle:3.1.4
.
I tried the following
buildTypes {
debug {
...
}
release {
...
}
unstripped {
...
packagingOptions {
doNotStrip '**/*.so'
}
}
}
but that makes all buildTypes to keep unstripped versions of the libraries.
I also tried changing the doNotStrip
pattern to something like '**/unstripped/*.so'
but that does not seem to help me, since the docs say that the path is related to the APK's root dir.
Here is a workaround for you:
Feeding a command line option "doNotStrip
"
Add below to your app/build.gradle
android {
...
if (project.hasProperty("doNotStrip")) {
packagingOptions {
doNotStrip '**/*.so'
}
}
...
}
Use below command to generate the unstripped apk by feeding option doNotStrip
to the command.
./gradlew assembleUnstripped -PdoNotStrip
For other build types, you can still use the normal build commands. e.g.
./gradlew assembleDebug
or
./gradlew assembleRelease
but don't feed option doNotStrip
to the command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With