5

I'm creating a piece of software that can deploy Android apps but the AndroidManifest that is located within the apk file is in a custom binary XML format. What I am trying to find out is if there is a tool that will allow me to add my own AndroidManifest.xml file into an apk (converting it to AXML when it is added), or is the format explained anywhere so I can create my own converter

Mat
  • 306
  • 1
  • 2
  • 12

3 Answers3

9

Figured this out using the Android packaging tool (aapt.exe)

aapt.exe package -f -m -J src -M AndroidManifest.xml -S res -A assets  -0 "" -I android.jar -F MyApp.apk

According to the docs:

-f
    force overwrite of existing files

-m
    make package directories under location specified by -J

-J
    specify where to output R.java resource constant definitions

-M
    specify full path to AndroidManifest.xml to include in zip

-S
    directory in which to find resources. Multiple directories will be scanned and the first match found (left to right) will take precedence

-A
    additional directory in which to find raw asset files

-0
    specifies an additional extension for which such files will not be stored compressed in the .apk. An empty string means to not compress any files at all.

-I
    add an existing package to base include set

-F
    specify the apk file to output

This takes a plain xml manifest and packages it into binary XML and inserts it into the apk.

Unfortunately it requires that the resources and assets be present (if you refer to them within the manifest file itself). I also have to add any other data back into the apk file. Not ideal but it works at least

0xcaff
  • 13,085
  • 5
  • 47
  • 55
Mat
  • 306
  • 1
  • 2
  • 12
3

xml2axml.jar

After a lot of research I have found a tool on Github which allows us to convert axml (Binary AndroidManifest.xml) to xml (Readable AndroidManifest.xml) and vice versa.

Download the xml2axml.jar file of the tool from release page here and then you can use these commands to decode axml and encode xml files.

Encoding xml files to axml:

java -jar xml2axml e [AndroidManifest-readable-in.xml] [AndroidManifest-bin-out.xml]

Decoding axml files to xml:

java -jar xml2axml d [AndroidManifest-bin-in.xml] [AndroidManifest-readable-out.xml]
  • Sorry brother, as i told earlier, i was in hurry when i found the solution. But i have added some help. Let me know if still you are stuck somewhere in this process. I am always available and willing to help. – Talha Asghar Apr 18 '20 at 16:47
2

Check out 'apktool': http://ibotpeaches.github.io/Apktool/

It can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. Also it makes working with an app easier because of project-like file structure and automation of some repetitive tasks like building apk, etc.

mostar
  • 4,723
  • 2
  • 28
  • 45
Christian Brüggemann
  • 2,152
  • 17
  • 23