Search code examples
androidc++java-native-interface

W/dalvikvm(16493): Bogus method descriptor: void (V)


Ok, I'm getting a Bogus method descriptor from my JNI code. I'm trying to get my class constructor method ID, and it's just not playing ball. I have also tried, (void) V , (V)V , (void) void

None of which works, However when I set an Int param and put a (I)V method descriptor, it works? but passing in an unused uneeded param is messy. I copied and pasted the method descriptor from the official JNI specification, I don't know why it doesn't work.

EDIT : And I'm doing the correct "" method name to...

Here's my C++ :

jmethodID methHelperContructor = env->GetMethodID(javaHelperClass, "<init>", "void (V)");

Here's my Java :

Gameplay3DHelper(){};

Solution

  • Not sure how to best piece this together other than just running a sample Java class through javah yourself and reading the comments.

    I think if you take this Wikipedia article and this JNI documentation together, make the connection between Java and Android, and then shake it a little, you might conclude that the correct type signature is ()V, for "takes no arguments, returns void".