昨晚编译NfcGuestKey的so文件的时候,发现新的so文件会导致APP崩溃,原来的确没有问题,比较了一下,大小区别很大,原来的30kb,新编译的60kb,而且原来的没有gdb.setup和gdbserver。
CheckOut原来的版本,用一样的代码,却发现还是30kb,仔细比较,发现30kb的版本没有obj\local\armeabi\objs-debug,也没有gdb.setup和gdbserver,莫非是NDK编译也存在debug和release版本的区别?
百度了NDK编译release,查找到如下文章:
Android NDK 设置编译模式debug和release
Unless you have created the Application.mk or defined your application as debuggable inside the AndroidManifest.xml you don't have to do anything because by default the application's modules are compiled in release mode by the ndk-build script.
Otherwise, you can use the APP_OPTIM directive inside the Application.mk file:
APP_OPTIM:=release
APP_PLATFORM:=android-14
APP_STL:=gnustl_static
APP_ABI:= armeabi armeabi-v7a
也就是NDK默认是编译release版本,除非AndroidManifest.xml设置了debuggable标志为true或者Application.mk中设置了APP_OPTIM,查看生成60kb so文件的两个工程,
果然android:debuggable="true",修改为android:debuggable="false"后,
重新
$NDK/ndk-build clean
$NDK/ndk-build
大小为30kb,不再生成obj\local\armeabi\objs-debug,gdb.setup和gdbserver。
本文探讨了Android NDK在debug和release模式下编译SO文件的区别,特别是如何通过修改AndroidManifest.xml和Application.mk来影响SO文件的大小,以及其对gdb.setup和gdbserver等调试工具的影响。
1436

被折叠的 条评论
为什么被折叠?



