问题 无法将ndk-gdb附加到Android应用程序


我试图将ndk-gdb附加到我的Android应用程序。

我正在使用的是 Android-ndk-r6b 和设备是Android 2.3,三星Galaxy S II。

我按照本例中的所有步骤操作 点击此处查看示例

当我尝试将gdb与另一个应用程序连接时,我尝试使用一个应用程序,但是详细说明它总是附加到第一个应用程序本身

Found package name: <1st attached package name>

我试图推出 ndk-gdb 首次使用此命令:

 ndk-gdb --start --force --verbose

我尝试使用以下命令附加到另一个应用程序但无法成功:

ndk-gdb --launch=com.example.hellogdbserver.HelloGdbServer --force --verbose

第一次申请我总是得到以下错误:

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

这是我得到的完整的shell日志

    sh-4.1$ ndk-gdb --verbose --start --force
    Android NDK installation path: /cygdrive/c/Android/android-ndk
    Using default adb command: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb
    ADB version found: Android Debug Bridge version 1.0.26
    Using final ADB command: '/cygdrive/c/Android/android-sdk-windows/platform-tools/adb'
    Using auto-detected project path: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver
    Found package name: com.example.hellogdbserver
    ABIs targetted by application: armeabi
    Device API Level: 10
    Device CPU ABIs: armeabi-v7a armeabi
    Compatible device ABI: armeabi
    Found debuggable flag: true
    Found device gdbserver: /data/data/com.example.hellogdbserver/lib/gdbserver
    Using gdb setup init: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver/libs/armeabi/gdb.setup
    Using toolchain prefix: /cygdrive/c/Android/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
    Using app out directory: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver/obj/local/armeabi
    ERROR: Could not extract package's data directory. Are you sure that
           your installed application is debuggable?
    sh-4.1$

请让我知道如何解决上述错误以及如何附加到新包。

我的手机没有扎根。希望这不会影响gdb。

这也没有用 链接到类似的问题。由于我的手机是新手机,没有任何应用程序,除了当前正在开发的应用程序。 (只有三星手机随附的包装。没有从市场上下载的应用程序。)

感谢和问候,
SSuman185


请仔细阅读链接 使用android ndk gdb在android应用程序中调试本机代码


1909
2017-11-25 09:13


起源

您是否尝试在清单中设置<application <! - ... - > android:debuggable =“true”>? - Lennart
是的我已将此标志设置为true - <application android:icon =“@ drawable / icon”android:label =“@ string / app_name”android:debuggable =“true”> - Suman
在我的三星Infuse上也看到了同样的情况。你有没有找到解决方案? - Androider


答案:


如果您尝试调试库项目,则会出现此问题。 ndk-gdb无法附加到不是“主”项目的项目。

您必须将您的jni代码放入启动应用程序项目中。


6
2017-08-01 09:05





请首先确保您正在构建应用程序的可调试版本。 AndroidManifest.xml文件应包含android:debuggable =“true”标记。

您还可以通过在bin目录中找到APK文件,解压缩它(它只是一个重命名的ZIP文件)并确保lib \ armeabi文件夹包含gdbserver文件来检查它。

如果满足上述两个条件,请尝试手动在设备上安装软件包:

<android-sdk>\platform-tools\adb.exe install -r <your-package-file.APK>

请仔细观察adb.exe的输出。如果它显示错误,它可能会解释您的问题。


5
2018-06-24 13:31



我没有在lib / armeabi文件夹中看到adbserver文件。我正在设置android:debuggable =“true”并且我正在运行ndk-build NDK_DEBUG = 1并且我在Application.mk中设置了APP_OPTIM:= debug。您对如何确保adbserver编译并插入armeabi文件夹有任何建议吗? - Cypress Frankenfeld


确保将jni / Application.mk中的APP_OPTIM设置为debug


3
2017-09-24 22:01



那面旗子做什么?它与NDK_DEBUG = 1不同吗? - Cypress Frankenfeld


根据 http://developer.samsung.com/forum/thread/ndk-debugging-with-gdb/77/178834 一些三星手机在没有root权限的情况下不是本机可调试的,因为run-as已被破坏

看到 run-as Package'a.b.c'未知 - Galaxy S4 Jellybean或Android 4.3 为我的解决方案


0
2018-06-20 20:09