解决UnsatisfiedLinkError: dlopen failed: cannot locate symbol "stpcpy" referenced by ".so"

解决 UnsatisfiedLinkError: dlopen failed: cannot locate symbol "stpcpy" referenced by "xxx.so" 的问题

网上搜到的原因是说这个问题是由于ndk 的 compile api 版本 21 遗弃了 stpcpy 以及其他一些接口,所以导致有些旧系统上面运行时会崩溃

Yes - the android libc headers have changed in API 21. Some functions that didn't exist previously were redirected to other functions in the older headers. Therefore you can't really build with API 21 if you want to run on older devices, unless you take great care to work around such issues. If you need to use newer native APIs from API 21 but still be compatible with older devices, you need to do manual work to achieve this anyway.
If you only want the newer API for the java side, just set a separate APP_PLATFORM=19
in Application.mk, while building the java side with a newer SDK.
See Cannot load library: reloc_library[1285]: cannot locate 'rand' for more details on this issue.

如果android studio 用的gradle 是 experimental 版本的话要设置 APP_PLATFORM 则需要如下设置:

android.ndk {
    toolchainVersion "4.9"    // DK_TOOLCHAIN_VERSION
 
    // APP_PLATFORM
    // Note this must be >=21 for 64 bit architectures
    platformVersion 21
 
    stl "c++_static"      // APP_STL
 
    // APP_ABI
    abiFilters.addAll(["armeabi-v7a", "arm64-v8a", "x86", "x86_64"
    ])
}

Building Native Android Libraries with the Latest Experimental Android Plugin

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,734评论 0 3
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,539评论 0 13
  • TABLE OF CONTENTS Introduction 7 Overview of FortiCloud 7...
    Bouw阅读 2,522评论 0 0
  • 2016.9.10-9.17 四国,不是说同时逛了四个国家,而是霓虹国一个地区的名字。它和更常听说的本州,北海道,...
    yan_1216阅读 705评论 0 1
  • 雨涵V:1779627690 hello大家好,我是您的好朋友雨涵,那么今天呢给大家分享了我自己写的一篇励志的文章...
    黎雨涵阅读 444评论 0 2