I am writing an Android app which communicates through jni with C++ (not C). I was able to successfully pass a jstring, so the setup works, but now I want to pass a jintarray. However, the code returns an Unsatisfied Link Error on the native method, so I think I am not properly returning a jintarray.
extern "C" {
JNIEXPORT jintArray JNICALL Java_com_example_optimuse_MainActivity_generate(JNIEnv* env, jobject thiz, jintArray arr);
};
JNIEXPORT jintArray JNICALL Java_com_example_optimuse_MainActivity_generate(JNIEnv* env, jobject thiz){
int mymusic[6];
mymusic[0]=60;
mymusic[1]=64;
mymusic[2]=67;
mymusic[3]=72;
mymusic[4]=67;
mymusic[5]=64;
jintArray jmymusic = env->NewIntArray(6);
env->SetIntArrayRegion(jmymusic, 0, 6, mymusic);
return jmymusic;
}
And I call this in java like this:
int[] music = generate();
I think I am doing something basic wrong. Any ideas?
@Michael OMG! You are right. This got cut off on my screen because of resolution 😉 Must have been there from all the testing I did with importing arrays.
Thanks a million, of course it should be