问题描述
我的项目使用NDK r10d作为c ++代码。
当我使用API19编译项目时,它工作得很好,但是当我使用API21编译它时,它会在运行时崩溃。
My project uses NDK r10d for the c++ code.When I compile the project with API19 it works great, but when I compile it with API21 it crashes on runtime.
当c lib被加载时,我得到了:
When the c lib is loaded I get:
然后它崩溃了:
我使用运行Android4.4.4的OnePlus One在两种情况下进行测试。
I use OnePlus One running Android4.4.4 to test it on both cases.
任何想法?
推荐答案
是的 - 在API 21中更改了android libc标头。以前不存在的一些函数被重定向到其他函数中旧标题。因此,如果您想在旧设备上运行,则无法使用API 21构建,除非您非常谨慎地解决此类问题。如果您需要使用来自API 21的更新的本机API但仍然与旧设备兼容,则无论如何都需要手动完成此操作。
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.
如果您只想要更新的Java方面的API,只需在 Application.mk
中设置一个单独的 APP_PLATFORM = 19
,同时构建java端使用较新的SDK。
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.
这篇关于使用API21进行编译时出现UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!