athlon
athlon

Reputation: 45

Android NDK JNI dot notation method signature variable

I have following method, which have multiple arguments dot notation :

static public void configure( Activity activity,String client_options, String app_id, String... zone_ids )

So now I want to call it like follow :

jmethodID configMethodID =(*env)->GetStaticMethodID(env, adcolonyclazz, "configure","(Landroid/app/Activity;Ljav/lang/String;Ljava/lang/String;[java/lang/String;)V");

But the all I got is :

java.lang.NoSuchMethodError: no static method with name='configure' signature='(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;[java/lang/String;)V'

Same goes with :

jmethodID configMethodID =(*env)->GetStaticMethodID(env, adcolonyclazz, "configure","(Landroid/app/Activity;Ljav/lang/String;Ljava/lang/String;Ljava/lang/String;)V");

Does anyone know the signature variable for this specific method. Thanks

Upvotes: 2

Views: 815

Answers (2)

bigh_29
bigh_29

Reputation: 2633

The accepted answer is correct, however, I struggled to figure out the right syntax for javap. Here are some commands that worked for me when run in the terminal window of Android Studio Giraffe on a Linux system. Start off in the root directory of the project.

Note: Do a full build of your project beforehand so your .class java output files are up to date. javap takes .class input, not source code input.

# Find where javap lives. I didn't have one on my path
find ~ -name javap

# Best javap candidate was found in ~/bin/android-studio/jbr/bin/javap

# Find the .class file for the class that you want to run javap on
find . -iname Foo.class

# .class file found in ./mygreatapp/build/intermediates/javac/debug/classes/com/awesomecompany/mygreatapp/packagename/Foo.class

# cd into the base directory for .class output. Stop at classes. Don't go into com/blahblah
cd ./mygreatapp/build/intermediates/javac/debug/classes

# Now we can run javap. I include -p because I needed private method signatures
~/bin/android-studio/jbr/bin/javap -s -p com/awesomecompany/mygreatapp/packagename/Foo.class

One final note. My command history shows that I once had to pass the android jar file as the bootclasspath argument to javap. I think that was because I wanted to dump out a system class instead of one of my classes. That command looked like this:

~/bin/android-studio/jbr/bin/javap -s -bootclasspath ~/Android/Sdk/platforms/android-31/android.jar android.os.Parcel

Upvotes: 0

user207421
user207421

Reputation: 310980

The correct signature is whatever is output by javap -s. Don't try to write signatures yourself when there is a tool that does it for you with 100% accuracy.

Upvotes: 2

Related Questions