Android NDK-使用通过不同API级别编译的库 [英] Android NDK - Using libraries compiled with a different API level

查看:136
本文介绍了Android NDK-使用通过不同API级别编译的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组用独立的工具链针对API 19和NDK rev 17编译的C/C ++库,是否可以在使用API​​ 26(最低SDK目标19)的项目中使用这些库?还是我需要使用API​​ 26重新编译它们?

I have a group of C/C++ libraries compiled with a standalone toolchain for API 19 and NDK rev 17, is it be possible to use these libraries on a project that uses API 26 (min SDK target 19)? Or do I need to recompile them using API 26?

在脚本中,make_standalone_toolchain.py询问--api参数,但是我不确定这是否应该是项目中使用的最小API或目标API.

In the script, make_standalone_toolchain.py ask for the --api argument but I am unsure if this is supposed to be the minimum API or the target API used on the project.

推荐答案

是否可以在使用API​​ 26(最低SDK目标19)的项目上使用这些库?

is it be possible to use these libraries on a project that uses API 26 (min SDK target 19)?

是的,有可能,但是可能并不理想.从下面的android-ndk-r17c/platforms结构中可以看到:

Yes, it is possible, but, may not be ideal. As seen from below android-ndk-r17c/platforms structure:

android-ndk-r17c 包含项目的最低API级别19,并且该API级别仅包含两种架构,即 arm x86 .这意味着您所有的编译都将分别引用和链接arch-armarch-x86内部的那些库.请注意,它们是32位ABI.将来,如果您必须包括64位ABI,例如x86_64arm64,我认为您至少需要使用--api 21重新编译本机代码(因为api 21,NDK开始支持64位ABI).

android-ndk-r17c contains your project minimal API level 19, and this API level only includes TWO architectures, i.e. arm and x86. This means all your compilation will refer and link with those libraries inside arch-arm or arch-x86 respectively. And note they are 32-bit ABIs. In future, if you have to include the 64-bit ABIs, e.g. x86_64 or arm64, I think you need to recompile your native code at least with --api 21 (since api 21, NDK starts to support 64-bit ABIs).

如果使用有问题的本机共享库的android项目是用minSdkVersion 21或更高版本21编译的,我建议您使用带有--api 21的独立工具链来编译本机代码.因为没有设置--api 19的附加值.

If your android projects using your native shared libraries in question are compiled with minSdkVersion 21 or above 21, I would suggest you compile your native code using the standalone toolchains with --api 21. Because there is no added value to set --api 19.

参考:

  • Ensure that your app supports 64-bit devices
  • Standalone Toolchains

这篇关于Android NDK-使用通过不同API级别编译的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆