美文网首页
解决UnsatisfiedLinkError: dlopen f

解决UnsatisfiedLinkError: dlopen f

作者: Gabo | 来源:发表于2017-06-06 20:18 被阅读943次

    解决 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

    相关文章

      网友评论

          本文标题:解决UnsatisfiedLinkError: dlopen f

          本文链接:https://www.haomeiwen.com/subject/xrenfxtx.html