5

I have Ant project with many modules. I'm trying to merge some modules into bigger ones and reduce their numbers.

Can I run android manifest merger as a stand-alone application and merge manifests specified as arguments?

For example i have modules: A, B, C, D, E

I need to [A], [B] become [AB] module, and [C], [D], [E] to become [CDE]

I need this because I'm writing Python script, which will help migrate to Gradle. Script will scan directories, and create new project with all files, copied classes and resources. I would like it to be universal.

Bresiu
  • 2,123
  • 2
  • 19
  • 31

1 Answers1

6

Ok, I would like to answer my own question.

manifest-merger is java library placed in ANDROID_HOME/tools/lib/manifest-merger.jar

To use jar as stand-alone application, I cloned project from google platform tools repository: git clone --depth=1 https://android.googlesource.com/platform/tools/base

Manifst-Merger source code is place under base/build-system/manifest-merger

Also you can find code at grepcode.

I extracted code into maven project, resolved all external dependencies and created project which can be cloned and use as stand-alone application:

https://github.com/Bresiu/android-manifest-merger

Usage:

  1. git clone git@github.com:Bresiu/android-manifest-merger.git

  2. mvn install

  3. java -jar target/manifest-merger-jar-with-dependencies.jar --main mainAndroidManifest.xml --log [VERBOSE, INFO, WARNING, ERROR] --libs [path separated list of lib's manifests] --overlays [path separated list of overlay's manifests] --property [PACKAGE | VERSION_CODE | VERSION_NAME | MIN_SDK_VERSION | TARGET_SDK_VERSION | MAX_SDK_VERSION=value] --placeholder [name=value] --out [path of the output file]

  4. I have used this library as follows:

java -jar target/manifest-merger-jar-with-dependencies.jar --main <path_to_main_manifest> --libs <path_to_libs_manifests_divided by ':'> --out <output_manifest> --log WARNING

Bresiu
  • 2,123
  • 2
  • 19
  • 31
  • thanks for this. after installing maven, adding `JAVA_HOME`, seems to work. however, got message _"`Error: Invalid parameter :, expected a command switch`"_ when trying to use `--libs`. I am in cygwin bash... – TT-- Dec 10 '18 at 18:01
  • 1
    I found that I have to use the semi-colon (';') as a separator, rather than the colon (':') – lionscribe Sep 02 '19 at 16:56