ERROR: Non-debuggable application installed on the target device. Please re-install the debuggable version!

注意,本文的描述,必须完全满足下面的条件,并且要确定已经在编译ndk的时候,已经使用了 NDK_DEBUG=1。并且打包APK的时候已经包含gdbserver,gdb.setup。

最近在调试NDK的时候,发现一个比较棘手的问题,一直报告错误“ERROR: Non-debuggable application installed on the target device. Please re-install the debuggable version! ”如下面所示:

$ ndk-gdb
WARNING: The shell running this script isn't bash.  Although we try to avoid bashism in scripts, things can happen.
/path_ndk/ndk-gdb: 214: /path_ndk/ndk-gdb: Bad substitution
ERROR: Non-debuggable application installed on the target device.
       Please re-install the debuggable version!

要求ndk-gdb输出详细的执行过程如下:

$ ndk-gdb.py --force --verbose
Android NDK installation path: /Android/android-ndk-r10e
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags: 
Using auto-detected project path: .
Found package name: com.xxxx.xxxx
ABIs targetted by application: Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml    
Device API Level: 18
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: 
Using gdb setup init: Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml    
Using toolchain prefix: Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml    
Using app out directory: Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml    
Found debuggable flag: true
ERROR: Could not find gdbserver binary under ./libs/
       This usually means you modified your AndroidManifest.xml to set
       the android:debuggable flag to 'true' but did not rebuild the
       native binaries. Please call 'ndk-build' to do so,
       *then* re-install to the device!

可以观察到几个奇怪的地方,比如,报错的地方提示"ERROR: Could not find gdbserver binary under ./libs/" ,正常情况下,应该是"./libs/armeabi-v7a","./libs/armeabi"之类的东西,并且“Compatible device ABI: ”部分,是不应该输出为空的情况的。这说明,没有正确的读取到APK中的关于CPU相关的数据。另外,注意这句话“WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml

庆幸的是,Google提供了Python版本的ndk-gdb 因此,我们在Ubuntu 15.04下面使用Spyder来跟踪调试,观察到底哪里出了问题。
设置如下:
Configure_Spyder
调整需要跟踪调试的目录到工程中正常执行ndk-gdb所在的目录:
Configure_Path
跟踪之后发现问题如下图所示:
ndk_gdb_py_bug

也就是说,当AndroidManifest.xml中设置的版本号“<uses-sdk android:minSdkVersion="14" />跟在 Application.mk 中设置的版本号“APP_PLATFORM := android-19”,当两者不一致的时候,会导致返回的APP_ABIS不是正常情况下的"[armeabi,armeabi-v7a]"这种形式的返回,而是返回了错误信息的详情,而这个仅仅是个警告而已,也就是说是Google 的一个BUG.

了解了原因,就比较好解决问题了,只要两者修改成为一致就可以了

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注