I compiled this library using NDK into an .so. I can successfully load it with System.LoadLibary() but when I try the example code for the library, it throws an UnsatisfiedLinkError. I checked the source code for the library and it indeed has the functions I’m using with the same parameters (except JNIEnv and jobject) along with the same returns. Plus, surely the creator of the library would share working example code. So what am I doing wrong? I copied the exact code from the page, and changed the variable names accordingly.
Share
Without more detail it’s difficult to say. Having looked at the library on that site, it’s possible that you’ve named your class differently. You need to call your Java class
Giffleand it has to be in the packageorg.jiggawatt.giffle. This isn’t a naming convention that you would stumble upon by accident 😉To use it, you would either make the calls in the
Giffleclass, or probably a cleaner way is to use an instance:Does seem a bit odd that the Java part wasn’t in the zip, especially as the class name is hardcoded into the C symbol. Maybe the guy who wrote it had a whole bunch of extra code in the Java part that he didn’t want anyone to see.
As far as I can tell, the C and C++ code is complete. You shouldn’t need to modify it at all. The implementations of the native methods are in gifflen.cpp, and have names like
Java_org_jiggawatt_giffle_Giffle_Init. They have the correct native-side arguments for the JNI calling convention.