JNI共享库似乎在发布版本

时间:2015-08-18 20:53:54

标签: android java-native-interface native

我是Android原生开发的新手。目前正致力于将库移植到Android平台并将其与app。

集成

我通过ndk-build命令行工具构建了库。在发布配置中,我指定了NDK_DEBUG=0选项,我实际上可以在源C / C ++文件中看到它们确实在发布配置中编译(NDEBUG已定义)。

但是,生成的.so文件似乎包含调试符号。使用编辑器打开文件我可以看到所有内部符号(变量和函数名称),这些符号不是由库导出的,因此它们显然不应出现在发布版本中。我的意思是,这个库文件.so将被包含在应用程序apk文件中并分发给客户端,世界上没有理由用户应该使用符号获取此文件。

那么,我该如何摆脱它们呢?我应该在ndk-build命令行或Android.mk文件中指定一个选项吗?

1 个答案:

答案 0 :(得分:0)

您应该使用zip文件中的APP_OPTIM := release以及Application.mk中的android:debuggable="false"

AndroidManifest.xml

顺便说一下,如果你仔细看看APP_OPTIM This optional variable can be defined to either 'release' or 'debug'. This is used to alter the optimization level when building your application's modules. A 'release' mode is the default, and will generate highly optimized binaries. The 'debug' mode will generate un-optimized binaries which are much easier to debug. Note that if your application is debuggable (i.e. if your manifest sets the android:debuggable attribute to "true" in its <application> tag), the default will be 'debug' instead of 'release'. This can be overridden by setting APP_OPTIM to 'release'. Note that it is possible to debug both 'release' and 'debug' binaries, but the 'release' builds tend to provide less information during debugging sessions: some variables are optimized out and can't be inspected, code re-ordering can make stepping through the code difficult, stack traces may not be reliable, etc... 实际上在做什么,你应该看到一个ndk-build命令,我认为有责任删除这些符号。