2

I have a native method in my Android Class as:

public native void decode(Bitmap pTarget, byte[] pSource);

When I try to create the header file using Eclipse Javah tool from Externla Configuration tools, I get a message that says:

Error: Cannot determine signature for Bitmap

This does not happen if I remove the native method declaration. How can I debug this issue to make sure javah can locate the signature for Bitmap?

sireesha
  • 147
  • 1
  • 5
  • 16
  • Before generating the header file using javah tool, I replaced Bitmap datatype by **Object**. When the header file is generated, I replaced the datatype **back to Bitmap** in both the header file and the java class containing the native method. Hopes this helps someone else. – sireesha Feb 28 '14 at 21:58
  • Does jni understands Bitmap ? I don't think so, you have to pass byte array of bitmap. – Yuvi Mar 01 '14 at 08:07

1 Answers1

3

The Bitmap class belongs to the package "android.graphics.Bitmap", so its JNI type is Landroid/graphics/Bitmap;

The complete method signature should be:

void Java_yourPackage_yourClass_decode__Landroid_graphics_Bitmap_2_3B (JNIEnv *env, jobject thiz, jobject pTarget, jbyteArray pSource)

Sources: http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp615 http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html

EDIT: the javah tool does not recognize Android classes, so you must add the classpath option to javah command. Try to look at this: https://stackoverflow.com/a/7635758/3370382

Community
  • 1
  • 1
Juggernaut93
  • 333
  • 1
  • 9