Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run android manifest merger as a stand-alone application

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.

like image 618
Bresiu Avatar asked Mar 16 '16 08:03

Bresiu


1 Answers

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 [email protected]: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

like image 126
Bresiu Avatar answered Sep 26 '22 05:09

Bresiu