classlink error java,java.lang.UnsatisfieldlinkError:找不到本地方法

我正在尝试使用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

/* 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

+0

检查您是否在lib目录下成功生成了.SO文件,如果没有.so文件,它将无法正常运行 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值