调试混合JNI代码的方法?

时间:2011-04-08 03:07:52

标签: c++ android debugging java-native-interface

我一直在寻找一种简单的方法来调试我的JNI代码,你知道,能够自由地跳转到本机代码并返回到java代码中。

我发现的解决方案有点过时或受到一些限制。一些需要特定的ndk版本,一些需要特定的Eclipse版本。我的目标是Android 1.6& 2.2,我正在使用Eclipse 3.6 Helios和NDK r5b。这种混合调试有一般的解决方案吗? THX。

1 个答案:

答案 0 :(得分:1)

来自$NDK/docs/NDK-GDB.html的Citate:

  

重要提示:本机调试只有在满足所有条件时才能工作:

1. Your application is built with the 'ndk-build' script:

    Building with the legacy "make APP=<name>" method is not
    supported by ndk-gdb.

2. Your application is debuggable:

    In other words, your AndroidManifest.xml has an <application>
    element that sets the android:debuggable attribute to "true"

3. You are running your application on Android 2.2 (or higher):

    ndk-gdb will not work if you try to run your application on
    previous versions of the system. That does not mean that your
    application should target the Android 2.2. API level, just
    that the debugging session should happen on a 2.2+ device or
    emulator system image.

所以,你不能使用1.6的设备。

如何设置环境以调试jni代码:我使用this recipe,它适用于我。