1.复制libs所有的库文件到项目中
2.复制提供的native所有的方法文件如上图所示NativeInterface文件(注意:该文件包括提供的所有的方法)
package com.example.hellojni;
public class NativeInterface {
static{
System.loadLibrary("HelloJni");
}
public native String getString();
public native int getInt();
}
强调:该文件要放到跟提供的编译头文件相同的包下面如图:com.example.hellojni
因为创建jni的时候就是使用到 包名+类名创建
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_hellojni_NativeInterface */
#ifndef _Included_com_example_hellojni_NativeInterface
#define _Included_com_example_hellojni_NativeInterface
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_example_hellojni_NativeInterface
* Method: getString
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_example_hellojni_NativeInterface_getString
(JNIEnv *, jobject);
/*
* Class: com_example_hellojni_NativeInterface
* Method: getInt
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_example_hellojni_NativeInterface_getInt
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif