android - 在 Android NDK 中使用比 Android Manifest 中的最低 API 更高的 API 是否有效?

标签 android c++ android-ndk clang

我有一个 Android 应用,指定最低 API 级别为 15,目标 API 为 17。通常,我指定 android-15 ( <ndk>/platforms/android-15 ) 作为我的 API 级别(通过 --sysroot )用于我的应用程序的 native 部分使用 Android NDK,因为 AFAIK 最低应该通过 NDK 定位。

但是,NDK r14 中的 Clang + LLVM STL 似乎存在一个错误,其中的符号如 strtold除非您使用 android-21最小值,否则无法正确定义在 NDK 端。

所以我的问题是:使用 *.so 有什么影响?为 android-21 编译APK 的最小 SDK 为 15,目标 SDK 为 17?我可以摆脱这个吗?

最佳答案

简短的回答:没有。查看我们的 Common Problems doc .

The target API level in the NDK has a very different meaning than targetSdkVersion does in Java. The NDK target API level is your app's minimum supported API level. In ndk-build, this is your APP_PLATFORM setting.

Since references to functions are (typically) resolved when a library is loaded rather than when they are first called, you cannot reference APIs that are not always present and guard their use with API level checks. If they are referred to at all, they must be present.

有点长,更迂腐的答案:只有在它不是真的更高的特殊情况下。例如,NDK 中没有 android-20。在这种情况下,您将退回到 android-19,因此可以将 NDK 目标 API 设置为 android-20,minSdkVersion 为 19,因为您实际上最终会使用 android-19无论如何。

关于android - 在 Android NDK 中使用比 Android Manifest 中的最低 API 更高的 API 是否有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43505958/

相关文章:

Android NDK - getFieldID 结果导致 NoSuchFieldError

android-ndk - 安卓NDK : Linking "error: undefined reference to" GLES functions

android - 保存数据时登录失败。(注册)

android - 在 Eclipse 中使用自定义 InstrumentationTestRunner 会导致错误

c++ - 使用strtok函数时出现的问题

c++ - 从指针读取时的 OpenMP 竞争条件

c++ - mkoct 文件错误

android - 如何获取Android NDK中编解码信息的角色?

android - 蓝牙 A2DP 配置文件

android - 带有游标加载器的 Volley 或 Service