debugging - Android - 如何启用 CheckJni 进行 NDK 开发?

标签 debugging java-native-interface android-ndk native-methods

如果我在这里遗漏了什么,有人可以告诉我吗? 我正在 shell 中尝试以下命令。

$ ./adb shell stop
$ ./adb shell setprop dalvik.vm.checkjni true
$ ./adb shell start

但是当我将 apk 安装到设备上时,Logcat 总是显示“CheckJNI is OFF”。
在 Eclipse 中我还需要做些什么来启用 XCheck:Jni 标志吗?

感谢您的帮助 BD

最佳答案

有四种不同的情况,一种用于 root 设备,一种用于模拟器,一种用于常规设备,一种用于 root 或常规设备。


在root设备上我能够让它工作:

在 adb 中:

adb shell

在这个 shell 之后启动:

su
stop
setprop dalvik.vm.checkjni true
start

此设备重新启动后并在启动时我看到日志消息:

CheckJNI is ON



对于其他情况,请参阅 official docs 中的一些理论:

There are several ways to enable CheckJNI.

If you’re using the emulator, CheckJNI is on by default.

If you have a rooted device, you can use the following sequence of commands to restart the runtime with CheckJNI enabled:

adb shell stop
adb shell setprop dalvik.vm.checkjni true
adb shell start

In either of these cases, you’ll see something like this in your logcat output when the runtime starts:

D AndroidRuntime: CheckJNI is ON

If you have a regular device, you can use the following command:

adb shell setprop debug.checkjni 1

This won’t affect already-running apps, but any app launched from that point on will have CheckJNI enabled. (Change the property to any other value or simply rebooting will disable CheckJNI again.) In this case, you’ll see something like this in your logcat output the next time an app starts:

D Late-enabling CheckJNI

You can also set the android:debuggable attribute in your application's manifest to turn on CheckJNI just for your app. Note that the Android build tools will do this automatically for certain build types.

关于debugging - Android - 如何启用 CheckJni 进行 NDK 开发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1818405/

相关文章:

android - 为android中的特定api级别编译c++

c++ - 调试 Qt 应用程序

python - 在 python 的 concurrent.futures 中查找 BrokenProcessPool 的原因

c - 变量取一定值时的断点

rust - 尝试在 JNI 中创建字符串并将其添加到 Arraylist

java - JNI 缓存的 jclass 全局引用变量被垃圾收集?

java - 当我尝试在 android studio 3 上构建 apk 时,它给了我错误

visual-studio - 对 slCreateEngine 的 undefined reference

ios - 调试 xcode 4 : says it's running application on device, 但实际上什么也没发生

android - 无法执行 JavaVM->DetachCurrentThread() : "attempting to detach while still running code"