解決 UnsatisfiedLinkError: dlopen failed: cannot locate symbol "stpcpy" referenced by "xxx.so" 的問題
網(wǎng)上搜到的原因是說這個問題是由于ndk 的 compile api 版本 21 遺棄了 stpcpy 以及其他一些接口兢仰,所以導致有些舊系統(tǒng)上面運行時會崩潰
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