0
jni를 사용하여 데모 어플리케이션을 만들려고합니다. 나는 봤 거든 그래서 문제에 대해 아무것도 도움이되지. 다음은 java.lang.UnsatisfieldlinkError : 네이티브 메소드를 찾을 수 없습니다.
내가 사용하고있는 코드입니다 :include $(CLEAR_VARS)
LOCAL_MODULE := example
LOCAL_SRC_FILES := com_example_example_Operacoes.c
include $(BUILD_SHARED_LIBRARY)
Operacoes.java 패키지 com.example.example;
public class Operacoes {
static {
System.loadLibrary("example");
}
//Versao nativa do metodo soma
public static native int soma(int a, int b);
//Versao nativa do metodo subtracao
public static native int sub(int a, int b);
}
com_example_example_Operacoes.h
# include "com_example_example_Operacoes.c"
JNIEXPORT jint JNICALL Java_com_example_example_Operacoes_soma (JNIEnv *, jclass, jint, jint);
int soma(int a, int b){
return a + b;
}
JNIEXPORT jint JNICALL Java_com_example_example_Operacoes_sub (JNIEnv *, jclass, jint, jint);
int sub(int a, int b){
return a - b;
}
com_example_example_Operacoes.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_example_Operacoes */
#ifndef _Included_com_example_example_Operacoes
#define _Included_com_example_example_Operacoes
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_example_example_Operacoes
* Method: soma
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_example_example_Operacoes_soma (JNIEnv *, jclass, jint, jint);
/*
* Class: com_example_example_Operacoes
* Method: sub
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_example_example_Operacoes_sub (JNIEnv *, jclass, jint, jint);
#ifdef __cplusplus
}
#endif
#endif
lib 디렉토리에 .SO 파일이 성공적으로 생성되었는지 확인하십시오 .so 파일이 없으면 제대로 실행되지 않습니다. – bladeX