在 Android 中使用新的“manifestmerger”属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10976635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:37:16  来源:igfitidea点击:

Using the new "manifestmerger" property in Android

androidandroid-manifestadtandroid-library

提问by android developer

In the newest version of ADT (version 20 preview 3), they say that it's possible to make the libraries' manifest file become mergeable with projects that use them:

在最新版本的 ADT(版本 20 预览版 3)中,他们说可以使库的清单文件与使用它们的项目合并:

Automatic merging of library project manifest files into the including project's manifest. Enable with the manifestmerger.enabled property.

自动将库项目清单文件合并到包含项目的清单中。使用 manifestmerger.enabled 属性启用。

How and where do I use it? I can't see content assist helping with me on this anywhere.

我如何以及在哪里使用它?我在任何地方都看不到内容帮助帮助我解决这个问题。

回答by Kevin McMahon

Add the following line to your project.propertiesfile of your application project.

将以下行添加到project.properties应用程序项目的文件中。

manifestmerger.enabled=true 

Introduced with Android SDK Tools, Revision 20 (June 2012):
https://developer.android.com/studio/releases/sdk-tools

Android 引入SDK Tools, Revision 20 (June 2012)https:
//developer.android.com/studio/releases/sdk-tools

Build System
    * Added automatic merging of library project manifest files into the including project's manifest.       Enable this feature with the manifestmerger.enabledproperty.

构建系统
    * 添加了库项目清单文件的自动合并到包含项目的清单中。使用manifestmerger.enabled属性启用此功能。

回答by Ratna Halder

If you want to merge android library project manifest and your current project manifest, you have to add manifestmerger.enabled=truein your project.properties file where you referred your library project. But, you should be confirmed some point like ADT version, Also Minimum and target SDK should be same as library project.

如果你想合并 android 库项目清单和你当前的项目清单,你必须manifestmerger.enabled=true在你引用你的库项目的 project.properties 文件中添加。但是,您应该确认一些点,例如 ADT 版本,并且最小和目标 SDK 应该与库项目相同。

回答by Vadimo

FYI: manifestmerger.enabled=true won't merge the manifest files if you are using eclipse export signed App. As noted here it seems to be a bug. http://code.google.com/p/android/issues/detail?id=34623

仅供参考:如果您使用 eclipse 导出签名的应用程序, manifestmerger.enabled=true 将不会合并清单文件。正如这里所指出的,这似乎是一个错误。 http://code.google.com/p/android/issues/detail?id=34623

It was a bit of a hassle for me to set up merging correctly as well. (restarting eclipse, open close project..) To find out if merging is working take a look at the file in ../Your_Main_Project/bin/AndroidManifest.xml. If merging worked you will see the complete result in this file.

正确设置合并对我来说也有点麻烦。(重新启动 eclipse,打开关闭项目..)要了解合并是否有效,请查看 ../Your_Main_Project/bin/AndroidManifest.xml 中的文件。如果合并成功,您将在此文件中看到完整的结果。

EDIT:This bug was fixed in ADT v20.0.1 (Juli 2012): http://developer.android.com/tools/sdk/eclipse-adt.html

编辑:此错误已在 ADT v20.0.1(2012 年 7 月)中修复:http: //developer.android.com/tools/sdk/eclipse-adt.html

回答by Sid M

I was facing some errors during manifest merging (R.java file went missing) so alternately I explicitly copied the manifest contents (e.g. I copied just the activity contents) from the library project manifest and put them in my main project manifest. That resolved the error and everything seems to be working well so far. Let me know if anyone feels this is not a recommended alternative to manifest merging.

我在清单合并过程中遇到了一些错误(R.java 文件丢失了),所以我或者我从库项目清单中明确复制了清单内容(例如,我只复制了活动内容)并将它们放在我的主项目清单中。这解决了错误,到目前为止一切似乎都运行良好。如果有人认为这不是清单合并的推荐替代方案,请告诉我。