java.lang.exceptionininitializererror in android ndk -
i'm trying simple addition program in android ndk. i'm getting following exception -
java.lang.exceptionininitializererror
java file-
public class mainactivity extends activity { private native void mymethod(int a,int b); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mymethod(4,5); } static { system.loadlibrary("native"); // here i'm getting exception } }
android.mk
local_path := $(call my-dir) include $(clear_vars) local_ldlibs := -llog local_module := native local_src_files := native.c include $(build_static_library)
native.c
#include <jni.h> #include <string.h> #include <android/log.h> #define debug_tag "ndksetupactivity" void java_com_example_additionndk_mainactivity_mymethod(jnienv * env, jobject this, jint a,jint b) { jint c=a+b; __android_log_print(android_log_debug, debug_tag, "addition: %d", c); }
i ran error once when running sample ndk (hello-jni). it's because android sdk version not compatible (default of example 1.5). try switch compatible sdk , modifiy manifest . case haven't build .c .so. use ndk-build cygwin64.
Comments
Post a Comment