Customizing Android manifest parts

I am developing an Android application for which I want to send several different apks for different languages ​​on the market (each language includes a huge set of files, and I want to avoid creating one huge apk with all language packs).

So I need to configure the manifest file bit for each language: for example. application package and possibly application version etc. I know how I can create a manifest template to manually insert my values ​​at specific points in a file (see this post ). The problem is that I use ant to prepare my production apk, but otherwise I am developing using Eclipse, and so I need my project working in the IDE. Eclipse requires a complete manifest file and does not understand the patterns that I will use to build ant, as far as I know (please someone will prove to me that I'm wrong).

My problem is that I want to avoid saving two manifest files that are pretty much identical (one template and one full for Eclipse). Currently, I can think of two possible approaches, but I do not know how to implement them:

  • Use any injection of the definition in the manifest file: if I can insert a specific xml file into the body of the AndroidManifest file, I can save the identical part in one part of the xml and adjust only the difference points
  • If you can configure Eclipse to use some ant task sequence to build Android projects instead of pre-build routines, I could integrate the way I create my production apk in the IDE.

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

+4
source share
2 answers

Look at ant to replace the task:

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

But again, you have to be careful with the values ​​that they are unique.

You can also replace the manifest of your eclipse with the generated manifest with the echoxml task.

Or you can reuse this nice task about xml processing.

+2
source

At the company I'm working on, we pretty much use the approach Eugen proposed to automate the process of building applications, for example, you just need to brand differently by exchanging certain assets, styles, lines and configurations. We tend to customize the project and build the process as follows:

  • Create an Android project and set it up so that it works for a specific branding. This will ensure that you can still create and run from Eclipse. Assuming the codebase does not change between versions released differently, this should be fine.
  • Create an ant build configuration that:
    • copies any files that will be changed to the backup directory
    • modifies project files according to the configuration file (see below)
    • compiles the sources of the project and signs it with the release key (when creating the assembly)
    • copies files from step 1, overwrites any changes and returns the project to its original state.
  • Create configuration files for each β€œbranding” or for language release in your scenario.

Basically, these steps will allow you to create branded / affiliate / language assemblies by simply providing the appropriate configuration with the ant build command. In our case, it looks something like this:

 ant partner-release -Dpartner=stackoverflow 

where "stackoverflow" will point to the configuration with the same name. In our case, these configuration files are small XML files containing all the parameters that must be replaced for a specific assembly. It may contain strings, but may also point to other files (for example, logo images) that should be copied to assets / resources. For instance:

 <config> <version_name>1.00</version_name> <version_code>1</version_code> ... </config> 

A few more pointers:

  • We use xmltask to modify any xml files in the project; e.g. manifest and resources.
  • Since the above task is really easy to use, our build configuration files are also configured as xml files as shown above. This is understandable to the user and easy and simple change.
  • You can also use replace and ReplaceRegExp tasks to change configuration-dependent variables in almost any file. The latter can be especially convenient for making changes to the build time in the source code.
+2
source

All Articles