Android jni开发中的常见错误

错误1:java.lang.UnsatisfiedLinkError: Native method not found: 本地方法没有找到

1、本地函数名写错

2、忘记加载.so文件 没有调用System.loadlibrary

错误2:findLibrary returned null

1、System.loadLibrary("libhello"); 加载动态链接库时 动态链接库名字写错

2、平台类型错误 把只支持arm平台的.so文件部署到了 x86cpu的设备上

查看帮助文档:

APP_ABI

By default, the NDK build system will generate machine code for the 'armeabi' ABI. This corresponds to an ARMv5TE based CPU with software floating point operations. You can use APP_ABI to select a different ABI.

For example, to support hardware FPU instructions on ARMv7 based devices, use:

          APP_ABI := armeabi-v7a

Or to support the IA-32 instruction set, use:

          APP_ABI := x86

Or to support the MIPS instruction set, use:

          APP_ABI := mips

Or to support all at the same time, use:

          APP_ABI := armeabi armeabi-v7a x86 mips

Or even better, since NDK r7, you can also use the special value 'all' which means "all ABIs supported by this NDK release":

          APP_ABI := all

For the list of all supported ABIs and details about their usage and limitations, please read CPU-ARCH-ABIS.

在jni目录下创建 Application.mk 在里面指定

APP_ABI := armeabi x86

重新编译后可以看到分成两个平台编译,生成2个.so文件

我们可以看到上面的编译过程中出现警告,可以在 Application.mk 指定:
APP_PLATFORM := android-8

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值