In my project, I have a wrapper class named PlayerCluster.java, which loads the native lib, and provides native functions. If I changed the class name (PlayerCluster.java) or its package, I get java.lang.UnsatisfiedLinkError when native function is invoked.
Why do I get this error when I rename the class name? Is there an approach by which native lib must be loaded in a specific java class?
If you rename the class then you must also rename your
JNIEXPORTmethods in your native library so they match the new Java class name and then rebuild your native lib.For example, given this method signture:
NativeMethodsis the Java class which, as you can see, is part of the native function signature.