Android - How to enable CheckJni for NDK development?
Asked Answered
G

3

5

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

Griz answered 30/11, 2009 at 7:58 Comment(1)
plz mention how you ever solved your problem .. That will be of great help... thanksHarpist
Y
8

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.

Yahweh answered 21/9, 2012 at 9:27 Comment(0)
B
3

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

Bacteriostat answered 11/1, 2010 at 16:37 Comment(0)
T
0

There is a section on how to use checkJNI here too:

http://www.netmite.com/android/mydroid/dalvik/docs/embedded-vm-control.html

Teazel answered 9/11, 2011 at 0:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.