qq_25494039
qq_25494039
采纳率0%
2018-11-20 11:00 阅读 704

Android studio 编写JNI 的demo时报错 ,Native method not found。

C文件
#include
#include
#include

jstring Java_com_MyJni_helloInC(JNIEnv* env, jobject thiz){
char* str = "hello from c!!";
return (*env)->NewStringUTF(env,str);
}

Java 文件

package com;

public class MyJni {
static {
System.loadLibrary("hello");
}
public native String helloInC();
}
错误信息:
FATAL EXCEPTION: main
Process: com.pedro.rtpstreamer, PID: 4196
java.lang.UnsatisfiedLinkError: Native method not found: com.MyJni.helloInC:()Ljava/lang/String;
at com.MyJni.helloInC(Native Method)
at com.pedro.rtpstreamer.MainActivity.jniHello(MainActivity.java:88)
at com.pedro.rtpstreamer.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐