android - UnsatisfiedLinkError when calling C++ method in C++ file from Java file -
it looks popular problem,
and still not find out solution.
package name : app.cloudstringers
java file : completed.java
static { try { system.loadlibrary("ffmpeg"); } catch (unsatisfiedlinkerror e) { log.d("", "error : " + e.tostring()); } } // define native method public native int getstring(); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.page_completed); // call native method log.d("", "" + getstring()); c++ file : ffmpeg.cpp
#include <jni.h> #include <android/log.h> #include <string.h> #ifdef __cplusplus extern "c" { #endif jniexport jstring jnicall java_app_cloudstringers_completed_getstring(jnienv* env, jobject thiz) { jstring strret = env->newstringutf("helloworld jni !"); return strret; } #ifdef __cplusplus } #endif android.mk file
local_path := $(call my-dir) include $(clear_vars) local_module := ffmpeg local_src_files := ffmpeg.cpp include $(build_shared_library) i run application still error exception unsatisfiedlinkerror : getstring
people know how fix problem,
please tell me,
thanks
update follow @dextor answer. sorry because mistake. thing need question change public native int getstring() public native string getstring().
it works now.
not sure (didn't try), wrong thing i've noticed return type of method declarations.
java-side
public native int getstring()
ndk-side
jniexport jstring jnicall java_app_cloudstringers_completed_getstring(jnienv* env, jobject thiz)
in java, have int. on c-side, have jstring.
Comments
Post a Comment