[英]How to include debug symbols for a pre-built native library inside an Android App Bundle?
When uploading an app to the play store that uses a native library its necessary to also upload the native debug symbols to get useful crash/ANR info.将应用程序上传到使用本机库的 Play 商店时,还需要上传本机调试符号以获取有用的崩溃/ANR 信息。
If you upload without symbols you receive the following warning: "This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."如果您上传时没有符号,您会收到以下警告:“此 App Bundle 包含本机代码,并且您尚未上传调试符号。我们建议您上传符号文件,以使您的崩溃和 ANR 更易于分析和调试。”
In the past when uploading apps as .apk
files it was necessary to manually upload such debug info.过去在将应用程序上传为
.apk
文件时,需要手动上传此类调试信息。 Now using .aab
if the native library is built via android studio its possible to set android.defaultConfig.ndk.debugSymbolLevel = 'FULL'
at which point when you build a the .aab
it will include the debug info automatically, you upload this single file and everything is done/working.现在使用
.aab
如果本机库是通过 android studio 构建的,则可以设置android.defaultConfig.ndk.debugSymbolLevel = 'FULL'
,此时当您构建.aab
时,它将自动包含调试信息,您上传此单文件,一切都已完成/工作。
However its not always possible/ideal/necessary to build a library inside android studio.然而,在 android studio 中构建库并不总是可能/理想/必要的。 Sometimes there are reasons for libraries to be externally pre-built and just used by android studio not built by it;
有时有一些原因需要在外部预先构建库并仅由 android studio 使用,而不是由它构建; Android studio supports this via a directory structure which is described here https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs In short you just copy the libraries into the correct
src/main/jniLibs/{ABI}
path(s) and it is picked up and made part of the bundle. Android Studio 通过此处描述的目录结构支持这一点https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs简而言之,您只需将库复制到正确的
src/main/jniLibs/{ABI}
路径,它被拾取并成为捆绑包的一部分。
.aab
that contains debug info that play store can understand so that you don't need to upload it manually. .aab
,其中包含 Play 商店可以理解的调试信息,因此您无需手动上传。.aab
..aab
中包含它们的调试信息。 Even though logically it should be possible to do this. I have searched everywhere I think but can't find anyone even talking about this really, how/where do you place the corresponding debug information so that that also can be included as part of the .aab
?我已经搜索了我认为的所有地方,但找不到任何人甚至真的在谈论这个,您如何/在哪里放置相应的调试信息,以便也可以将其作为
.aab
的一部分包含在内? Is there a separate path for this, do they just need a specific file extension, does gradle need to be told what to do with them somehow?是否有单独的路径,它们是否只需要特定的文件扩展名,是否需要告诉 gradle 以某种方式处理它们? Is it really just not possible?
这真的不可能吗?
Things I have tried:我尝试过的事情:
.so.dbg
extension and place them alongside the .so files - they aren't included in the .aab
.so.dbg
的文件,并将它们放在 .so 文件旁边 - 它们不包含在.aab
中.aab
- this appears to work but isn't the same convenience wise as having them in the .aab
.aab
后手动压缩和上传符号 - 这似乎有效但不一样将它们放在.aab
中一样方便After some more digging I found the task responsible for this is "ExtractNativeDebugMetadataTask" with which some effort can likely be tailored/altered to do custom things here.经过更多挖掘后,我发现负责此任务的任务是“ExtractNativeDebugMetadataTask”,可以通过它来定制/更改一些工作以在此处执行自定义操作。
However this ended up being unnecessary as while digging into this I discovered that it actually already works.然而,这最终是不必要的,因为在深入研究时我发现它实际上已经有效。 At least as of now in latest gradle versions (not sure about the past).
至少到目前为止最新的 gradle 版本(不确定过去)。 It was only failing due to some NDK path confusion which doesn't fail the build/creation of the bundle building but just logs an easy to miss informational message.
它只是由于某些 NDK 路径混淆而失败,这不会导致包构建的构建/创建失败,但只会记录一条容易错过的信息消息。
Ultimately all you need to do to make this work is:最终,完成这项工作所需要做的就是:
.so
files with -g
-g3
or similar-g
-g3
或类似工具构建您的外部.so
文件jniLibs
directory structure un-strippedjniLibs
目录结构中android{ ndk { debugSymbolLevel 'FULL' } ndkPath "$projectDir/path/to/NDK" }
android{ ndk { debugSymbolLevel 'FULL' } ndkPath "$projectDir/path/to/NDK" }
Resulting .aab
will contain the stripped .so
files and the split-debug .so.dbg
files all in the right location.生成的
.aab
将在正确的位置包含剥离的.so
文件和拆分调试的.so.dbg
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.