I am developing an android app using C++ code. Trying using JNI but failed. here is my code: from test.c in jni folder:
jstring Segment_com_example_segment_BrowsePicture_test( JNIEnv* env, jobject thiz )
{
return (*env)->NewStringUTF(env, "test");
}
I already build by ndk and generate libtest.so. but in my BrowsePicture.java (under Segment.com.example.segment) I added
public native String test();
But I couldn't call it. the message is :
E/AndroidRuntime(16748): java.lang.UnsatisfiedLinkError: Native method not found: com.example.segment.BrowsePicture.test:()Ljava/lang/String;
So can anyone tell me what's wrong?
try with change method name by this...
jstring Java_com_example_segment_BrowsePicture_test( JNIEnv* env, jobject thiz )
instead of this...
jstring Segment_com_example_segment_BrowsePicture_test( JNIEnv* env, jobject thiz )
Have you declared another class like the one below
package com.yourpackage;
public class NativeLib {
static {
System.loadLibrary("yourlibrary");
}
public static native void your_function(your_arguments);
}
Then call this function from your activity using
NativeLib.your_function(your_arguments);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With