自定义 Android Manifest 的部分 [英] Customizing parts of Android Manifest

查看:22
本文介绍了自定义 Android Manifest 的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Android 应用程序,我想为市场上的不同语言发布几个不同的 apk(每种语言都包含大量文件,我想避免创建一个包含所有语言包的巨大 apk).

I am developing Android application for which I want to ship several different apks for different languages in the market (every language includes a huge bundle of files and I want to avoid creating one huge apk with all language bundles).

所以我需要的是为每种语言自定义一点 Manifest 文件:例如应用程序包,可能还有应用程序版本等.我知道如何模板清单,以便我可以在文件的某些点手动插入我的值(请参阅 这篇文章).问题是我使用 ant 来准备我的生产 apk,否则我使用 Eclipse 进行开发,所以我也需要我的项目在 IDE 中工作.Eclipse 需要完整的 Manifest 文件,并且不了解我将用于 ant 构建的模板(请有人证明我错了).

So what I need is to customize a bit the Manifest file for each language: e.g. the package of the application and possibly the application version etc. I know how I can template the manifest so that I can manually insert my values in certain points in the file (see this post). The problem is that I use ant for preparing my production apks, but otherwise I develop using Eclipse and so I need my project working in the IDE too. Eclipse requires complete Manifest file and will not understand of the templating I will use for the ant builds as far as I know (please somebody prove me wrong).

我的问题是我想避免维护两个大部分相同的清单文件(一个是模板化的,一个是完整的用于 Eclipse).目前我可以想到两种可能的方法,但我不知道如何实现它们:

My problem is that I want to avoid maintaining two manifest files that are identical in large part (one templated and one complete for Eclipse). Currently I can think of two possible approaches, but I do not know how to accomplish them:

  • 在清单文件中使用某种定义注入:如果我能够在 AndroidManifest 文件的正文中注入某个 xml 文件,我可以将相同的部分保留在一个 xml 部分中,并仅自定义不同点
  • 如果可以将 Eclipse 配置为使用一些 ant 任务序列来构建 Android 项目,而不是使用预构建例程,我可能能够集成我在 IDE 中构建生产 apk 的方式.

请如果有人知道如何完成上述两个中的任何一个,或者有任何其他想法我该如何解决我的问题:帮助!

Please if there is anyone who knows how to accomplish any of the above two, or has any other idea how can I solve my issue: help!

推荐答案

看看蚂蚁替换任务:

<replace file="${build.out}/src/config.prop" token="@@@" value="${build.version}-${build.type}"/>

但同样,您应该注意它们是唯一的值.

But again you should be careful with values that they are unique.

您还可以用 echoxml 任务生成的清单替换您的日食清单.

You could also replace your eclipse manifest with generated manifest by echoxml task.

或者你可以重用这个不错的 任务关于xml操作.

Or you could reuse this nice task about xml manipulation.

这篇关于自定义 Android Manifest 的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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