1

in Java ,the native method :

public native String hello();

package name:  pack

class name: Hello

C++: method name:

jstring
Java_pack_Hello_hello
(
    JNIEnv* env,
    jobject this
)

I use ndk compile this file ,but app crash ;

after i add this line : extern "C" into my hello.cpp the error is gone ,every thing is ok.

so why ?

User_1191
  • 981
  • 2
  • 8
  • 24
belle tian
  • 897
  • 8
  • 20

1 Answers1

1

The format of method names used in JNI is different to regular C and C++ if you don't specify extern 'C' JNI will be unable to find the function to match your Java native declarations. alternatively you can try RegisterNatives()

vignesh karnika
  • 111
  • 1
  • 5