如果我在这里遗漏了什么,有人可以告诉我吗? 我正在 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/