Android的库清单与应用程序清单 [英] Android Library Manifest vs. App Manifest

查看:210
本文介绍了Android的库清单与应用程序清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里读到类似的问题,但我仍不清楚的一对夫妇的事情。使用库项目意味着我的整个项目将有两个清单 - 一个用于库,另一个是主的应用程序的项目 - 我并不清楚发生的事情,其中​​或有一定的冗余度

我正在开发一个应用程序窗口小部件精简版和有偿的版本,所以将有几乎所有code库中的项目。作为一个小窗口,该库将至少有一个接收器,一个服务,配置活动,加上几个其他活动。所以应该在哪里这些组件的完整声明 - 包括意图,过滤器等 - 被宣布?难道他们走在清单中的库,或在清单应用程序包本身,引用的类在库(例如机器人:名称=com.foo.mylibrary.MyService)?

我已经看了一些例子似乎宣布他们在这两个清单,但我怀疑,在一个把这些或另一种是无操作。

解决方案
  

使用图书馆计划意味着我的整个项目将有两个清单 - 一个用于库,另一个是主的应用程序的项目 - 我并不清楚发生的事情,其中​​或有一定的冗余度

<打击>库项目清单是不是presently使用。

摇篮为Android,因此Android的工作室,支持库项目和亚洲遥感协会发布清单。这可以包括像活动的声明,权限或功能,或最低支持的Andr​​oid SDK的水平。

该规则如何库清单合并到应用程序本身的表现 - 尤其是当你把生成类型和产品口味的考虑 - 是的有点复杂

  

那么,应该这些组件的完整声明 - 包括意图,过滤器等 - ?声明

<打击>在主体项目。

该库可以发布这些组件,然后在Android工作室主机项目可根据需要将其删除。

  

难道他们走在清单中的库,或在清单应用程序包本身,引用的类在库(例如机器人:名称=com.foo.mylibrary.MyService)?

<打击>后者。

在任何(与摇篮为Android和Android工作室)。从理论上讲,它是比较容易的库来发布的组件,所以该应用作者不必。就个人而言,我不是这方面的一个巨大的风扇,因为太多的开发商将结束不必要的发货清单项目。

I've read similar questions here, but am still not clear on a couple of things. Using a Library Project means that my overall project will have two manifests -- one for the library and the other for the "main" app project -- and I'm not clear what goes in which or if there is some redundancy.

I'm developing an app widget with "lite" and "paid" versions, so will have almost all code in a library project. Being a widget, the library will have at least a receiver, a service, a configuration activity, plus a couple of other activities. So where should the full declarations of these components -- including intents, filters, etc. -- be declared? Do they go in the manifest for the library, or in the manifest for the application package itself, referencing the classes in the library (e.g. android:name="com.foo.mylibrary.MyService")?

Some examples I've looked at seem to declare them in both manifests, but I suspect that putting these in one or the other is a no-op.

解决方案

Using a Library Project means that my overall project will have two manifests -- one for the library and the other for the "main" app project -- and I'm not clear what goes in which or if there is some redundancy.

The library project manifest is not presently used.

Gradle for Android, and therefore Android Studio, support library projects and AARs publishing a manifest. This can include things like activity declarations, required permissions or features, or minimum supported Android SDK levels.

The rules for how library manifests are merged with the app's own manifest -- particularly when you take build types and product flavors into account -- is a bit complex.

So where should the full declarations of these components -- including intents, filters, etc. -- be declared?

In the host project.

The library could publish those components, and the Android Studio host project can then remove them if needed.

Do they go in the manifest for the library, or in the manifest for the application package itself, referencing the classes in the library (e.g. android:name="com.foo.mylibrary.MyService")?

The latter.

In either (with Gradle for Android and Android Studio). In theory, it is easier for the library to publish the components, so the app author does not have to. Personally, I am not a huge fan of this, as too many developers will wind up shipping unnecessary manifest entries.

这篇关于Android的库清单与应用程序清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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