I'm trying to call the java code from S. This method call:
cls = (* env) -> FindClass (env, "org / libsdl / app / SDLActivity");
mid =开发者_如何学编程 (* env) -> GetStaticMethodID (env, cls, "play",
"([Ljava / lang / String;) V");
(* env) -> CallVoidMethod (env, cls, mid);
java method:
public static void play () {
track.write (bytes, 0, bytes.length);
}
Cause this error:
03-25 18:17:32.313: WARN / dalvikvm (655): JNI WARNING: JNI method called with exception raised 03-25 18:17:32.313: WARN / dalvikvm (655): in Lorg / libsdl / app / SDLActivity;. main (ILjava / lang / String; [I (GetByteArrayElements) 03-25 18:17:32.313: WARN / dalvikvm (655): Pending exception is: 03-25 18:17:32.323: INFO / dalvikvm (655): Ljava / lang / NoSuchMethodError;: play
finds the class, but can not find a method What's the problem? How to decide?
The problem is that the method signature string is incorrect. For a method with no arguments returning void, the method signature string is "()V"
.
Another point is that a valid type or method signature string will never have spaces in it. Thus a method that takes a String argument and returns void would be
"([Ljava/lang/String;)V"
rather than
"([Ljava / lang / String;) V"
It looks like you're trying to find a method that takes a String parameter when the method in fact takes no parameter.
精彩评论