java - Android NDK UnsatisfiedLinkError Native method not found -
unsatisfiedlinkerror while running android ndk app. have read the android dev jni tips on error. , far can tell doing correctly. have studied jni spec, doesn't seem help. need jni_onload method? optional. need kind of header soundtouch-jni.cpp file? don't think so.
basics: package io.hpp.soundtouch
, class soundtouch
, java call native method string getversionstring()
, c++ method extern "c" jstring java_io_hpp_soundtouch_soundtouch_getversionstring(jnienv *env, jobject thiz)
error log:
06-09 18:11:44.817: d/dalvikvm(4510): trying load lib /data/app-lib/io.hpp.starspace-1/libsoundtouch.so 0x41ee0530 06-09 18:11:44.817: d/dalvikvm(4510): added shared lib /data/app-lib/io.hpp.starspace-1/libsoundtouch.so 0x41ee0530 06-09 18:11:44.817: d/dalvikvm(4510): no jni_onload found in /data/app-lib/io.hpp.starspace-1/libsoundtouch.so 0x41ee0530, skipping init 06-09 18:11:44.817: w/dalvikvm(4510): no implementation found native lio/hpp/soundtouch/soundtouch;.getversionstring:()ljava/lang/string; 06-09 18:11:44.817: d/androidruntime(4510): shutting down vm 06-09 18:11:44.817: w/dalvikvm(4510): threadid=1: thread exiting uncaught exception (group=0x4160fba8) 06-09 18:11:44.817: e/androidruntime(4510): fatal exception: main 06-09 18:11:44.817: e/androidruntime(4510): process: io.hpp.starspace, pid: 4510 06-09 18:11:44.817: e/androidruntime(4510): java.lang.unsatisfiedlinkerror: native method not found: io.hpp.soundtouch.soundtouch.getversionstring:()ljava/lang/string; 06-09 18:11:44.817: e/androidruntime(4510): @ io.hpp.soundtouch.soundtouch.getversionstring(native method) 06-09 18:11:44.817: e/androidruntime(4510): @ io.hpp.starspace.starspaceactivity.oncreate(starspaceactivity.java:61) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activity.performcreate(activity.java:5231) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activitythread.performlaunchactivity(activitythread.java:2159) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activitythread.access$800(activitythread.java:135) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 06-09 18:11:44.817: e/androidruntime(4510): @ android.os.handler.dispatchmessage(handler.java:102) 06-09 18:11:44.817: e/androidruntime(4510): @ android.os.looper.loop(looper.java:136) 06-09 18:11:44.817: e/androidruntime(4510): @ android.app.activitythread.main(activitythread.java:5017) 06-09 18:11:44.817: e/androidruntime(4510): @ java.lang.reflect.method.invokenative(native method) 06-09 18:11:44.817: e/androidruntime(4510): @ java.lang.reflect.method.invoke(method.java:515) 06-09 18:11:44.817: e/androidruntime(4510): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 06-09 18:11:44.817: e/androidruntime(4510): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 06-09 18:11:44.817: e/androidruntime(4510): @ dalvik.system.nativestart.main(native method) 06-09 18:16:44.870: i/process(4510): sending signal. pid: 4510 sig: 9
this copy of soundtouch-jni.cpp file using:
#include <jni.h> #include <android/log.h> #include "include/soundtouch.h" //#define logv(...) __android_log_print((int)android_log_info, "soundtouch", __va_args__) //#define logv(...) //#define dll_public __attribute__ ((visibility ("default"))) using namespace soundtouch; extern "c" jstring java_io_hpp_soundtouch_soundtouch_getversionstring(jnienv *env, jobject thiz) { const char *verstr; //logv("jni call soundtouch.getversionstring"); // call example soundtouch routine verstr = soundtouch::getversionstring(); // return version string return env->newstringutf(verstr); }
this copy of soundtouch.java file
package io.hpp.soundtouch; public final class soundtouch { // native interface function returns soundtouch version string. // invokes native c++ routine defined in "soundtouch-jni.cpp". public native final string getversionstring(); // load native library upon startup static { system.loadlibrary("soundtouch"); } }
i figured out. well, not really. restarted eclipse , worked. woot woot!
Comments
Post a Comment