Today, I found a strange phenomenon using JNI. So developed by my colleagues. There is no problem in the android2.3 system, and the system above android4.0 will run out of the following exception information:
W/dalvikvm( 3191): JNI WARNING: received null jstringW/dalvikvm( 3191): in Lcom/avd/dev;.OpenCamera:(Ljava/lang/String;ILjava/lang/String;ILjava/lang/String;ILjava/lang/ String;ILjava/lang/String;Ljava/lang/String;I)J (GetStringUTFChars)I/dalvikvm( 3191): "main" prio=5 tid=1 NATIVEI/dalvikvm( 3191): | group="main" sCount=0 dsCount=0 obj=0x40d7a460 self=0x106abe0I/dalvikvm( 3191): | sysTid=3191 nice=0 sched=0/0 cgrp=default handle=1075057912I/dalvikvm( 3191): | schedstat=( 0 0 0 ) utm=205 stm=63 core=0I/dalvikvm( 3191): at com.avd.dev.OpenCamera(Native Method)I/dalvikvm( 3191): at com.raycommtech.ipcam.imp.p2p.SocketClient.opencamera(SocketClient.java:117)I/dalvikvm( 3191): at com.raycommtech.ipcam.imp.p2p.MediaFetchRayCommP2P.opencamera(MediaFetchRayCommP2P.java:623)I/dalvikvm( 3191): at com.raycommtech.rayfastcfg.service.RayFastcfgService.openCamera(RayFastcfgService.java:106)I/dalvikvm( 3191): at com.raycommtech.rayfastcfg.wlan.WifiConfigActivity$WorkHandler.handleMessage(WifiConfigActivity.java:170)I/dalvikvm( 3191): at android.os.Handler.dispatchMessage(Handler.java:99)I/dalvikvm( 3191): at android.os.Looper.loop(Looper.java:137)I/dalvikvm( 3191): at android.app.ActivityThread.main(ActivityThread.java:4444)I/dalvikvm( 3191): at java.lang.reflect.Method.invokeNative(Native Method)I/dalvikvm( 3191): at java.lang.reflect.Method.invoke(Method.java:511)I/dalvikvm( 3191): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)I/dalvikvm( 3191): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)I/dalvikvm( 3191): at dalvik.system.NativeStart.main(Native Method)I/dalvikvm( 3191): E/dalvikvm( 3191): VM aborting
Check the prompt. It is obvious that the jstring type parameter is null. After reading it online, someone has encountered a similar problem.
Solution: when calling the getstringutfchars () function, first determine whether the input jstring type variable is null, so you do not need to call this function.
Refer to blog:
Http://blog.csdn.net/hpccn/article/details/8112377