views:

3017

answers:

2

This file appears to be in a binary XML format. What is this format and how can it be parsed programmatically (as opposed to using the aapt dump tool in the SDK)?

This binary format is not discussed in the in the documentation here: http://developer.android.com/guide/topics/manifest/manifest-intro.html

Note: I want to access this information from outside the Android environment, preferably from Java.

+2  A: 

You can use axml2xml.pl tool developed a while ago within android-random project. It will generate the textual manifest file (AndroidManifest.xml) from the binary one.

I'm saying "textual" and not "original" because like many reverse-engineering tools this one isn't perfect and the result will not be complete. I presume either it was never feature complete or simply not forward-compatible (with newer binary encoding scheme). Whatever the reason, axml2xml.pl tool will not be able to extract all the attribute values correctly. Such attributes are minSdkVersion, targetSdkVersion and basically all attributes that are referencing resources (like strings, icons, etc.), i.e. only class names (of activities, services, etc.) are extracted correctly.

However, you can still find these missing information by running aapt tool on the original Android app file (.apk):

aapt l -a <someapp.apk>

Shonzilla
Thanks @Shonzilla. I need package name and version code information, the aapt does the job. As I am working with LAMP, I run aapt command in PHP and process the output with PHP.
hongster
+2  A: 

There is an application that reads apk files and decodes XMLs to nearly original form.

Check android-apktool.

Macarse