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 应用程序如何处理两个清单文件的问题。主要内容包括库项目和主应用项目之间的清单合并规则,特别是涉及到活动声明、权限和最低支持的 Android SDK 版本。作者指出,虽然库项目可以包含组件声明,但过多的不必要的清单条目可能导致问题。建议明确组件应在应用项目中声明,或者根据需要在库项目中声明并由应用项目移除。

被折叠的 条评论
为什么被折叠?



