Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ndk jni No implementation found error

I'm working with android and trying to use some native code in my app.

Here is a skeleton of the application code:

package A.B;
/*
import statements
*/

public class C extends Activity{

public void onCreate(...){
    ....
    foo();
    ....
}

public int foo(){
    .....
    data(a, b);
    .....
}

public int data(a, b){
    GetValues(a, b);
}

static{
    System.loadLibrary("baz");
}

public native int GetValues(int[] a, int b);
}

the native method signature goes like this:

JNIEXPORT jint JNICALL

Java_A_B_C_GetValues(JNIEnv *env, jobject obj, jintArray arr, jint b){

....

....

} 

while running the logcat shows up: W/dalvikvm(799): No implementation found for native LA/B/C;.GetValues ([IJ)I

the ndk documentation doesnt strictly mention creating a header file, so i dont have one

the android.mk file's contents:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := baz
LOCAL_SRC_FILES := baz.cpp

include $(BUILD_SHARED_LIBRARY)

Thanks in advance.

like image 986
jayant Avatar asked Dec 20 '22 21:12

jayant


1 Answers

Since your native file is a .cpp file, I am guessing that you will need to use extern "C". Why and Why

like image 173
bobby Avatar answered Jan 14 '23 15:01

bobby