对于Android库项目,为<使用的SDK>有意义的清单中? [英] For android library projects, is <uses-sdk> meaningful in manifest?

查看:118
本文介绍了对于Android库项目,为<使用的SDK>有意义的清单中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是所有pretty的多的称号。虽然我看<使用-SDK> 中的所有示例库项目的的Andr​​oidManifest.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.

其实,我怀疑&LT;使用-许可&GT; 也无关紧要,因为是全部&LT的属性;清单&GT; ,除了

In fact, I suspect that <uses-permission> is also irrelevant, as are all of the attributes of <manifest>, other than package.

谁能证实?

推荐答案

库清单可以合并与主应用程序清单。这是一个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  

[我不知道如何启用它在其他(如行家)建立;请在这里评论,如果你看着办吧。我猜它转换成一个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.

相对于这里提出的具体问题(合并的&LT;使用的SDK>和&lt;采用-许可>),为&LT规则;采用-SDK>是:

Relative to the specific questions raised here (merging of <uses-sdk> and <uses-permission>), the rules for <uses-sdk> are:

  • 的minSdkVersion:如果错误目标清单中包含的值不是的lib值;离开目标的价值是相同或大于LIB值,仅存储如果没有指定过那里(默认为1,如果在任一指定)的目标LIB值。
  • targetSdkVersion:警告,如果目的地清单中包含的值不是的lib值;离开目标的价值是相同或大于LIB的价值,存放在只有指定有没有目标LIB值(默认为合并后的minSdkVersion值,如果在任一指定)。

有关&LT规则,使用,权限>是:添加库权限到目的地,如果他们是不是已经present那里。这是确定的,如果相同的权限是两者兼而有之。

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.

我创建了一个小的测试库项目和测试应用程序,使用它,为了得到对这个自己的底部。我提供了一个&LT;使用的SDK>和&LT;使用-许可>在库项目的清单,并从应用程序的清单中省略他们两个。

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.

其结果是,该库项目的&LT;使用的SDK>和&lt;使用-许可>值没有合并到在构建时应用,证明通过使用检查我的设备上安装应用程序的<一个href="https://play.google.com/store/apps/details?id=com.sonyericsson.androidapp.AppExplore&hl=en">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.

我的测试code可在<一href="https://github.com/adennie/android-library-project-manifest-test">https://github.com/adennie/android-library-project-manifest-test.

My test code is available at https://github.com/adennie/android-library-project-manifest-test.

我的结论是,指定&LT;使用的SDK>和&lt;使用-许可>在Android库项目的清单对消费应用程序的合并清单没有任何影响。

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库项目,为&lt;使用的SDK&GT;有意义的清单中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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