Android JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception
The Abort message is relatively clear: you call GetFieldID(cls, fieldName)
for a field name that does not exist in the class you pass to this function, but you don't check for that error, and continue to call other JNI functions. Unfortunately, you cannot ignore such errors. You must call ExceptionClear()
before calling GetMethodID()
or most of the JNI functions.
You can use addr2line to find which specific call to getMethodID()
crashed, and based on this, derive which call to GetFieldID(cls, fieldName)
failed. But I would advise to add error checking to all your JNI calls, because tomorrow some other function may throw an exception.
I have the same problem,and it confuse me 2 days.Finally the reason is that I pass the wrong object type.For example, the java code is
public OverlayLine(int mWidth,List<GeoPoint> mPoints);
and I register jni method as below:
gClass.mInitMethod = env->GetMethodID(gObject, "<init>", "(ILjava/lang/Object;)V");
and gets the error message as Errol encounter.And I fix the code
gClass.mInitMethod = env->GetMethodID(gObject, "<init>", "(ILjava/util/List;)V");
and the error gone.That you should pass the precise object type rather than 'Ljava/lang/Object;'.