gpt4 book ai didi

android - Android 库应该定义 targetSdkVersion 吗?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:46:32 24 4
gpt4 key购买 nike

我理解为什么库定义 minSdkVersion 很有用,但是具有定义的 targetSdkVersion 的库是否增加任何值(value)?

我不确定 targetSdkVersions 比主项目低和高的库是否会出现任何问题。如果主项目定义了它们,它们会被忽略吗?或者,拿较低的/较高的? Android 应用可以在不同的 targetSdkVersion 下以不同方式工作(例如,Marshmallow 运行时权限)。

最佳答案

关于 targetSDKVersion 的文档:

An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion.This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).

Android 库 targetSdkVersion 将告诉主机应用程序您的库在这方面应该如何表现。 list 合并有关于合并targetSdkVersion的特定规则:

enter image description here

Attributes in the element always use the value from the higher-priority manifest, except in the following situations:

  • When the lower-priority manifest has a minSdkVersion value that'shigher, an error occurs unless you apply the overrideLibrary mergerule.
  • When the lower-priority manifest has a targetSdkVersion value that'slower, the merger tool uses the value from the higher-prioritymanifest, but it also adds any system permissions that are necessaryto ensures that the imported library continues to function properly(for cases in which the higher Android version has increasedpermission restrictions). For more information about this behavior,see the section about implicit system permissions.

关于android - Android 库应该定义 targetSdkVersion 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35465502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com