对于android库项目,是<uses-sdk>在清单上有意义吗? [英] For android library projects, is <uses-sdk> meaningful in manifest?
问题描述
这几乎都在标题中.虽然我看到在所有示例库项目的AndroidManifest.xml
中都指定了
,但我觉得它无关紧要.
It's all pretty much in the title. Although I see <uses-sdk>
specified in all the example library project's AndroidManifest.xml
I've seen, I have a feeling it's irrelevant.
事实上,我怀疑
也无关紧要,
的所有属性也是如此,除了 包
.
In fact, I suspect that <uses-permission>
is also irrelevant, as are all of the attributes of <manifest>
, other than package
.
谁能确认一下?
推荐答案
截至 ADT r20 预览 3
库清单可以与主应用程序清单合并.这是通过指定属性在 ant 构建中启用的
As of ADT r20 preview 3
Library manifests can be merged with the main application manifest. This is enabled in an ant build by specifying the property
manifestmerger.enabled=true
[我不确定如何在其他(例如 maven)构建中启用它;如果你想通了,请在这里发表评论.我猜它会转化为一个 aapt 命令行参数.]
[I'm not sure how to enable it in other (e.g. maven) builds; please comment here if you figure it out. I'm guessing it translates into an aapt command line argument.]
各种规则管理冲突和压倒一切的行为.
A variety of rules govern conflicts and overriding behavior.
相对于这里提出的具体问题(
Relative to the specific questions raised here (merging of <uses-sdk> and <uses-permission>), the rules for <uses-sdk> are:
- minSdkVersion:如果目标清单包含的值小于 lib 值,则会出错;保留目标值等于或大于 lib 值,仅当未指定目标时才将 lib 值存储在目标中(如果两者均未指定,则默认为 1).
- targetSdkVersion:如果目标清单包含的值小于 lib 值,则发出警告;保留目标值等于或大于 lib 值,仅当未在目标中指定 lib 值时才将 lib 值存储在目标中(如果两者均未指定,则默认为合并的 minSdkVersion 值).
<uses-permission> 的规则是:将库权限添加到目标,如果它们尚未存在.如果两个权限相同就可以了.
The rule for <uses-permission> is: add library permissions to destination if they are not already present there. It's OK if the same permission is in both.
我创建了一个小测试库项目和一个使用它的测试应用程序,以便自己深入了解这个项目.我在库项目的清单中提供了一个 <uses-sdk> 和一个 <uses-permission>,并从应用程序的清单中省略了它们.
I created a little test library project and a test app that uses it, in order to get to the bottom of this myself. I provided a <uses-sdk> and a <uses-permission> in the library project's manifest, and omitted both of them from the application's manifest.
结果是库项目的 <uses-sdk> 和 <uses-permission> 值在构建时没有合并到应用程序中,这可以通过使用 AppXplore 工具.
The result was that the library project's <uses-sdk> and <uses-permission> values were NOT merged into the application at build time, as evidenced by examining the installed app on my device using the AppXplore tool.
我的测试代码可在 https://github.com/adennie/android-library-project-manifest-test.
我的结论是,在 Android 库项目的清单中指定 <uses-sdk> 和 <uses-permission> 对消费应用程序的合并清单没有影响.
My conclusion is that specifying <uses-sdk> and <uses-permission> in an Android Library Project's manifest has no effect on the merged manifest of the consuming application.
这篇关于对于android库项目,是<uses-sdk>在清单上有意义吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!