android - Getting exception on first NDK app -



android - Getting exception on first NDK app -

i'm starting larn ndk. i've downloaded recent ndk tools , eclipse plugin. i've followed basic tutorial , tried run. i'm getting work without eclipse plugin(calling manually ndk-build) plugin excepsion:

02-17 17:49:01.477: e/androidruntime(9746): java.lang.unsatisfiedlinkerror: performoperation

here code:

package com.helloworld; import android.os.bundle; import android.app.activity; import android.view.menu; public class helloworld extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_hello_world); nativelibrary nativeobject = new nativelibrary(); nativeobject.result(this); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.hello_world, menu); homecoming true; } }

and:

package com.helloworld; import android.content.context; import android.widget.toast; public class nativelibrary { /* * * performoperation defined in native library */ public native string performoperation(); /* * * loads library shared object */ static { system.loadlibrary("nativelibrary"); } /* * * computes result */ public void result(context ctx) { toast.maketext(ctx, performoperation(), toast.length_short).show(); } }

cpp:

#include <jni.h> jniexport jstring jnicall java_com_helloworld_nativelibrary_performoperation( jnienv* env, jobject o) { homecoming env -> newstringutf("this nativelibrary"); }

android.mk:

local_path := $(call my-dir) include $(clear_vars) local_module := nativelibrary local_src_files := nativelibrary.cpp include $(build_shared_library)

in cpp file, add together extern "c"{} around function:

extern "c" { jniexport jstring jnicall java_com_helloworld_nativelibrary_performoperation( jnienv* env, jobject o) { homecoming env -> newstringutf("this nativelibrary"); } }

android eclipse-plugin android-ndk

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -