I´m working on an application (developed with .NET Framework) that manages Android Application packages (apk) and the program has to read the ApplicationManifest.xml that resides inside the apk. Extracting the Manifest file from the apk is no problem, because I can use standard zip tools to extract all files from an apk.
But reading the ApplicationManifest is not possible. I expected that it contains raw XML data, but it's somehow encrypted or encoded.
Is there a way using the BCL of the .NET Framework to read the XML data from the ApplicationManifest? Or is there a library for the .NET Framework to read the ApplicationManifest?
I would not recommend using the mentioned apktool, as it is not safe for automated decoding - I used to use it for the same reason as you did, but it failed in some cases.
There are some tools like axml2xml that are specialized in Android encoded XML files or other tools like Android Asset Packaging Tool (aapt). You can also code a decoder on your own.
axml2xml is not perfect, so I would recommend running aapt (included in Android SDK) on your apk, as it print a lot of information you can parse:
aapt l -a <your.apk>
If you want to implement code to parse the Manifest yourself, have a look at ribo's community wiki entry:
In conclusion, I would recommend parsing the
aapt
output (you could bundle it with your application).Afaik, the easiest (and most commonly used) way to do this is to run the apktool utility as an external command and have it extract the AndroidManifest.xml for you (if you need it in its raw form), e.g. call
which will decode AndroidManifest.xml and place it in your output directory for you to read. It's executable on both Windows, OSX and Linux so you if you don't mind some external dependencies in your .NET apps..