将doNotStrip packagingOptions设置为特定的buildType [英] Set doNotStrip packagingOptions to a specific buildType
问题描述
我的项目有3种不同的buildType,我只需要其中一种来保留其本机库的调试信息.我正在使用com.android.tools.build:gradle:3.1.4
.
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
.
我尝试了以下
buildTypes {
debug {
...
}
release {
...
}
unstripped {
...
packagingOptions {
doNotStrip '**/*.so'
}
}
}
但这会使所有buildType保留未压缩的库版本.
but that makes all buildTypes to keep unstripped versions of the libraries.
我还尝试将doNotStrip
模式更改为类似'**/unstripped/*.so'
的方式,但这似乎无济于事,因为
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.
推荐答案
这是为您解决的方法:
提供命令行选项"doNotStrip
"
Feeding a command line option "doNotStrip
"
-
在下方添加到您的
app/build.gradle
android {
...
if (project.hasProperty("doNotStrip")) {
packagingOptions {
doNotStrip '**/*.so'
}
}
...
}
使用以下命令通过将选项doNotStrip
馈入命令来生成未剥离的APK .
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
或
./gradlew assembleRelease
但不要将选项doNotStrip
输入命令.
but don't feed option doNotStrip
to the command.
这篇关于将doNotStrip packagingOptions设置为特定的buildType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!