NDK CMAKE No implementation found for java.lang.String

E/art: No implementation found for java.lang.String com.psyberia.viberreplicant.MainActivity.getNativeKey1() (tried Java_com_psyberia_viberreplicant_MainActivity_getNativeKey1 and Java_com_psyberia_viberreplicant_MainActivity_getNativeKey1__)
05-01 20:38:12.782 11325-11325/com.psyberia.viberreplicant D/AndroidRuntime: Shutting down VM

Add the lines "extern "C""

#include <jni.h>#include <string>
extern "C" 
JNIEXPORT jstring JNICALLJava_com_psyberia_viberreplicant_MainActivity_stringFromJNI(JNIEnv *env, jobject /* this */) {
    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}
extern "C" 
JNIEXPORT jstring JNICALLJava_com_psyberia_viberreplicant_MainActivity_linker(JNIEnv *env, jobject /* this */) {
    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}
extern "C" 
JNIEXPORT jstring JNICALLJava_com_psyberia_viberreplicant_MainActivity_getNativeKey1(JNIEnv *env, jobject /* this */) {

    return env->NewStringUTF("TmF0aXZlNWVjcmV0UEBzc3cwcmQx");
}
extern "C"
 JNIEXPORT jstring JNICALLJava_com_psyberia_viberreplicant_MainActivity_getNativeKey2(JNIEnv *env, jobject /* this */) {

    return env->NewStringUTF("TmF0aXZlNWVjcmV0UEBzc3cwcmQy");
}
 
 
 
MainActivity
 
public native String stringFromJNI();
public native String linker();
public native String getNativeKey1();
public native String getNativeKey2();

// Used to load the 'native-lib' library on application startup.static {
    System.loadLibrary("native-lib");
}
 
 

@Overrideprotected void onCreate(Bundle savedInstanceState) {
.... 
String key1 = new String(Base64.decode(getNativeKey1(), Base64.DEFAULT));
String key2 = new String(Base64.decode(getNativeKey2(), Base64.DEFAULT));

}

Комментариев нет:

Отправить комментарий