JNI Warnig was expecting a return of type 'L' calling LocationManager.requestLocationUpdates

I am using Necessitas (QT on Android). Basically, using Andrid NDK, the android activity triggers the QT application (.so).

I am working on some GPS bindings. I think I get there, however I get JNI WARNING ( JNI Warnig expected return type "L" ) when I call the requestLocationUpdates (String, Long, Float, LocationListener) method.

Here are some of the code:

midGetSystemService = currEnv->GetMethodID(actClass,"getSystemService","(Ljava/lang/String;)Ljava/lang/Object;"); jSystemServiceObj = currEnv->CallObjectMethod(currAct,midGetSystemService,StringArg); midRequestLocationUpdates = currEnv->GetMethodID(locManClass,"requestLocationUpdates","(Ljava/lang/String;JFLandroid/location/LocationListener;)V"); midConstListener = currEnv->GetMethodID(listenerClass, "<init>", "()V"); jListenerObj = currEnv->NewObject(listenerClass, midConstListener); currEnv->CallObjectMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj); --->Here is the warning 

Any idea why?

+8
android android-ndk jni
source share
1 answer

You call the method that returns "void":

 midConstListener = currEnv->GetMethodID(listenerClass, "<init>", "()V"); 

using a JNI call that expects a JNI object as a result:

 // BAD currEnv->CallObjectMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj); 

Instead, you should use a JNI call that expects void to return:

 // GOOD currEnv->CallVoidMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj); 
+16
source share

All Articles