zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    看淘宝营销api 文档有感
    创业公司如何做好数据驱动的开发工作
    docker 常见错误总结
    从npm 角度理解 mvn 的 pom.xml
    best practices for designing web api
    我对自动化测试的一些认识
    Docker学习笔记
    Docker命令学习
    JVM学习笔记三:垃圾收集器与内存分配策略
    JVM学习笔记二:JVM参数
  • 原文地址:https://www.cnblogs.com/wuyudong/p/5633167.html
Copyright © 2011-2022 走看看