4

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.

Yury
  • 20,618
  • 7
  • 58
  • 86
jayant
  • 473
  • 1
  • 6
  • 12

1 Answers1

11

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

bobby
  • 2,629
  • 5
  • 30
  • 56