0

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?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Kyborg2011
  • 608
  • 3
  • 11
  • 29

2 Answers2

6

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"
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
2

It looks like you're trying to find a method that takes a String parameter when the method in fact takes no parameter.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373