Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to enable CheckJni for NDK development?

Can someone please tell me if I'm missing something here? I am trying the following commands in shell.

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

But Logcat always shows "CheckJNI is OFF" when I install the apk onto the device.
Is there something else in eclipse that I need to do to enable the XCheck:Jni flag?

Thanks for any help BD

like image 937
vamsibm Avatar asked Nov 30 '09 07:11

vamsibm


2 Answers

There is four different cases, one for rooted device, one for emulator, one for regular device and one for rooted or regular device.


On rooted device I was able to get it working so:

In adb:

adb shell

In launched after this shell:

su
stop
setprop dalvik.vm.checkjni true
start

After this device was rebooted and at boot I see log message:

CheckJNI is ON



For other cases see some theory from 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.

like image 123
Playful Curiosity Avatar answered Oct 14 '22 08:10

Playful Curiosity


See http://android-developers.blogspot.com/2011/07/debugging-android-jni-with-checkjni.html for all the alternatives.

like image 40
Elliott Hughes Avatar answered Oct 14 '22 08:10

Elliott Hughes