如何在AAR文件中的共享库中使用ndk-stack [英] How to use ndk-stack with shared library in AAR file
问题描述
我在Android应用程序中使用共享库.这些共享库在.aar
文件中.
I'm using shared object libraries in Android application. These shared object libraries are in .aar
file.
一个库崩溃了.为了检查崩溃日志和确切的行号.我正在用ndk-stack
接过.
One of library is crashing. In order to check crash logs and exact line no. I am using ndk-stack
took.
ndk-stack
的用法是
$ adb logcat | ndk-stack -sym <Path to your shared libraries>
现在如何在AAR文件中获取共享库的路径?
Now How can I get a path of shared libraries in AAR file?
推荐答案
您应该记住,并非每个.so
文件都对ndk-stack
有用. Android NDK生成两种.so
文件:已剥离和未剥离.最大的不同是,最后一个包含调试信息,而ndk-stack
则需要,而第一个则不需要. readelf
可能有助于检查是否删除了特定文件:
You should keep in mind that not every .so
file is useful for ndk-stack
. Android NDK produces two kinds of .so
files: stripped and non-stripped. The most difference is that last ones contain debug information, that is needed for ndk-stack
and first ones don't. readelf
may help to check if particular file is stripped or not:
$ readelf <non-stripped-lib> -S | grep debug
[23] .debug_info PROGBITS 00000000 00302c 0052d9 00 0 0 1
[24] .debug_abbrev PROGBITS 00000000 008305 000879 00 0 0 1
[25] .debug_loc PROGBITS 00000000 008b7e 001aa7 00 0 0 1
[26] .debug_aranges PROGBITS 00000000 00a628 000088 00 0 0 8
[27] .debug_ranges PROGBITS 00000000 00a6b0 0000d0 00 0 0 1
[28] .debug_line PROGBITS 00000000 00a780 0009de 00 0 0 1
[29] .debug_str PROGBITS 00000000 00b15e 002387 01 MS 0 0 1
[30] .debug_frame PROGBITS 00000000 00d4e8 0003d0 00 0 0 4
$
$ readelf <stripped-lib> -S | grep debug
$
如您所见,未剥离的ELF有很多.debug_*
部分,的确包含行号,私有/静态函数名称等.
As you see not-stripped ELF has a lot of .debug_*
sections, that indeed contain line numbers, private / static function names, etc.
接下来,.aar
个文件(包括调试文件和发布文件)仅具有 stripped 二进制文件.因此它们对于ndk-stack
毫无用处.
Next, .aar
files, both debug and release ones, has only stripped binaries. So they are useless for ndk-stack
.
AFAIK,唯一可以找到未剥离二进制文件的位置是obj/
目录.它的位置在某种程度上取决于所使用的构建系统:
AFAIK, the only place where non-stripped binaries may be found is a obj/
dir. Its location depends slightly on used build system:
- 对于
ndk-build
,它位于<module_name>/build/intermediates/ndk
下
对于基于 - 位于
<module_name>/build/intermediates/cmake
下
CMake
的- for
ndk-build
it is under<module_name>/build/intermediates/ndk
- for
CMake
-based it is under<module_name>/build/intermediates/cmake
另外,似乎开箱即用的android gradle插件无法将未剥离的库打包到您的aar
中,因此,唯一的方法是在build.gradle
中执行一些自定义任务.
Also it looks like out-of-the-box android gradle plugin offers no way to pack unstripped libraries to your aar
, so the only way here is some custom task in your build.gradle
.
这篇关于如何在AAR文件中的共享库中使用ndk-stack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!