jayant
jayant

Reputation: 493

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.

Upvotes: 4

Views: 8765

Answers (1)

bobby
bobby

Reputation: 2789

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

Upvotes: 11

Related Questions