[英]No implementation found for c++ and java on NDK
这是我的app/src/main/cpp/rtspinterface.cpp
#include <jni.h>
#include <android/log.h>
#include <string>
extern "C" JNIEXPORT jstring JNICALL Java_com_rtsp_RtspInterface_helloWorld(
JNIEnv *env, jobject thiz) {
return (*env)->NewStringUTF(env, "Hello from JNI !".c_str());
}
这是app/src/java/com/rtsp/RtspInterface.java
package com.rtsp;
public class RtspInterface {
public static native String helloWorld();
static {
System.loadLibrary("myRtspClient");
}
}
我越来越:
no implementation found for Java.lang.String.com.rtsp.RtspInterface.helloWorld() (tried Java_com_rtsp_RtspInterface_helloWorld and Java_com_rtsp_RtspInterface_helloWorld__)
这是确切时间的源代码树:
我从这里遵循命名约定https://developer.android.com/training/articles/perf-jni
我正在这样调用代码:
Log.v("test", RtspInterface.helloWorld());
原来我完全忘记为该cpp文件添加CmakeLists.txt。 它根本不是在编译。
我做了
cmake_minimum_required(VERSION 3.4.1)
add_subdirectory("../../../../../myRtspClient/myRtspClient" myRtspClient_bin)
add_library(rtspInterface SHARED rtspInterface.cpp)
target_link_libraries(rtspInterface android log)
它起作用了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.