Wednesday, March 5, 2008

Tool to read Android binary XML files

I have successfully reverse engineered a good portion of the Android binary XML file format that is found inside of Android package files (.apk). With this tool, you can explore the XML layout, drawable, and animation files used in the applications distributed with the SDK (phone, browser, contacts, etc). My primary motivation for doing this was to simply observe some of the common practices and get a sense for what Google is doing internally that isn't necessarily available through their API demos and samples. Below you can find two links to download either the stand-alone convertor or the collected output as run over every APK file found in the phone's /system directory:

Download: axml2xml.pl
Download: android-xmldump.tar.gz

Please note that this tool was a very quick hack and some of the XML files I found failed to parse. Not many, and the only ones I found were raw XML documents (not Android resources) so I didn't bother to explore any further incompatibilities. If you find any resources that fail to parse or have any insight into the format, feel free to leave a comment and I will investigate when I have time.

EDIT 2012-08-22: Android's come a long way since this post.  It's now possible to use the aapt tool to read the contents of XML documents (and a whole lot more) of APK files.  For example:

android dump xmltree foo.apk AndroidManifest.xml

26 comments:

IntelliBitz Technologies said...

Fantastic! Looks interesting.. am downloading now. Thanks for sharing.

Selmi said...

works for me, but in my project i get strange runtime errors for which i can't find reason... error says: Runtime Exception: Binary XML file line #xxx, you must supply a layout_width attribute.

unfortunately it says that error on line 121 on xml which in text form has 70 lines.

so maybe you can add some mode when output xml would be formatted such way that it would have content on same line numbers as binary xml so i will be able to see what is exactly there?

dain said...

just wanted to say thanks, this dump is a life-saver :)

Jack said...

Josh, can you put a note on how to run the script on a layout xml file? I don't know Perl. =(

Josh Guilfoyle said...

As any other UNIX tool, it accepts either a file for input on the command-line as the first argument, or fed through stdin, so:

./axml2xml.pl foo.xml > foo.xml.txt

Jack said...

Thank you Josh. Your tool enabled me to learn how the animation xml files work (xml files within android.jar).

Very cool.

sahn0 said...

For everyone: I've created similar tool in Java: AXMLPrinter. It is part of Android4ME project. Tool and its source is available on downloads tab.

For Josh: thank you for string table insight, though your assumption about how tags are encoded was not quite correct.

AK said...

For Josh: Thanks for posting the Perl script. However (start n00b mode here), I can't run it - I get this error:

Can't locate loadable object for module Unicode::String in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ./axml2xml.pl line 24
Compilation failed in require at ./axml2xml.pl line 24.

Any idea? I'm using Ubuntu 8.10.
Thanks,
Amir

AK said...

Sorry about previous post - my bad - I have not installed the package properly. Now that I did, I get a different error:

Out of memory during array extend at /home/amir/bin/axml2xml.pl line 314, <> chunk 1.

J said...

I could run this script on Windows with ActivePerl with no problem but when I run on Mac OS X with ActivePerl, I got

Out of memory during array extend at axml2xml.pl line 314, <> chunk 1.

Any idea?

wow gold said...

If you wow gold were in wow gold any doubt buy wow gold that the buy wow gold God Wars cheap wow gold Dungeon was cheap wow gold challenge enough wow power leveling for you, wow power leveling look no further power leveling than the giant power leveling demon, K’ril wow gold Tsutsaroth. Once buy wow gold thought of as cheap wow gold nothing more world of warcraft gold confirm his existence.

Amir Alagic said...

Hi

I am getting error message:

Out of memory during array extend at axml2xml.pl line 314, <> chunk 1

On Windows XP and ActivePerl. Any idea how to use your software on XP?

Thanks!

amanda said...

We export our stock shoes to more than 80 countries every year, and we are still growing. We give large buyers, container buyers 70%-90% discount. We do stock shoes business more than 10 years, we can offer you unbeatable prices, better than 98% factory-direct prices. The price depend on the quantity. We can mix many styles in one container (20ft GP, 40ft GP, 40ft HQ) for you.
www.AmandaShoesWholesale.com, No. 1 trusted online discount wholesale shoes site.
AmandaIEC located in Yiwu, is a trusted one stop B2B export, trade, sourcing, wholesale site. You needn't to look for lots and lots Chinese small-and-medium-sized enterprises on B2B platform like alibaba.com, and then inquiry them one by one. You just send us an inquiry in detail, we do all other things. Browse Alphabetically: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0-9. Start your one stop China wholesale sourcing here today and experience first class service and fast shipping. Save your time, save your cost, and guard against fraud. Need yiwu agent? Contact now!

goldsrunescape said...

runescape
runescape gold
runescape money
runescape powerleveling
runescape power leveling
runescape
runescape gold
runescape money
runescape powerleveling
runescape power leveling
runescape
runescape gold
runescape money
lotro
lotro gold
lotro powerleveling
lotro power leveling
lotro money
lotro
lotro gold
lotro money
lotro powerleveling
lotro power leveling
world of warcraft money
world of warcraft gold
wow gold
wow money
maplestory mesos
maple story mesos
maplestory mesos
maple story mesos
runescape
runescape gold
runescape money
runescape
runescape gold
runescape money

wowgold said...

It is what we buy cheap wow gold call 'the syndrome of the passive patient'. Basically we can't have anything with nothing and we know that if the client does not implicate himself cheap wow gold or herself a little bit financially then he or she won't make the effort later on and make
biodegradable cutlery the changes which are truly necessary. This is why it is essential for me that the wow gold people I help implicate themselves and sell cheap wow gold why I do not work for free. It is very important for me to know that I am not working pointlessly on an individual's analysis, wow gold producing a reading that wow gold 5000 will not be fully read or assimilated while all I really want to do is to pass on the valuable information which SRO gold. is going to so radically wow gold 10000
change your life Isis. Experience has shown me that the only means for me to be absolutely certain that the person who requests my work Get free WOW gold is going wow gold sale to make the effort and implicate himself or herself to bring about real change is to ask for a small financial participation. Isis, you will understand that if you don't want pulp egg tray to spend a few dollars to ask me to produce this full reading for you whilst I have already spent over
food container 10 hours on your file without asking you for anything at all in return (once again please understand
SRO gold

Travel in China said...

China Highlights
China Highlights
China Tours
China Hotels
China Attractions
Beijing China Travel
Shanghai China Travel
Xi'an China Travel
Guilin China Travel
Yangshuo China Travel

xxmy said...

Weekends to people ig2tmean that they can have a two-day wowgold4europe good rest. For example, people [url=http://www.gameusd.org]gameusd[/url]can go out to enjoy themselves or get meinwowgold together with relatives and friends to talk with each storeingame other or watch interesting video tapes with the speebie whole family.
Everyone spends agamegold weekends in his ownmmofly way. Within two days, some people can relax themselves by listening to music, reading novels, or watching ogeworld films. Others perhaps are more active by playing basketball, wimming or mmorpgvip dancing. Different people have different gamesavor relaxations.
I often spend weekends withoggsale my family or my friends. Sometimes my parents take me on a visit to their old friends. Sometimesgamersell I go to the library to study or borrow some books to mmovirtex gain much knowledge. I also go to see various exhibition to broaden rpg trader my vision. An excursion to seashore or mountain resorts is my favorite way of spending weekends. Weekends are always enjoyable for me.

belrion said...

buy wow gold

buy wow gold

buy wow account

buy wow gold

xuemei said...

Now do you worried about that in the game do not had enough wakfu kamas to play the game, now you can not worried, my friend told me a website, in here you can buy a lot wakfu gold and only spend a little money, do not hesitate, it was really, in here we had much wakfu money, we can sure that you will get the wakfu kama, quick to come here to buy wakfu kamas.

Now do you worried about that in the game do not had enough runescape gold to play the game, now you can not worried, my friend told me a website, in here you can buy a lot rs gold and only spend a little money, do not hesitate, it was really, in here we had much runescape money, we can sure that you will get the cheap rs gold, quick to come here to buy runescape.

coco0610 said...

wholesale jewelryhandmade jewelryjewelry wholesalefashion jewelrycostume jewelrywholesale costume jewelry wholesale fashion jewelrywholesale pearlwholesale crystaldiscount jewelrycheap jewelry

xxmy said...

Weekends to people ig2tmean that they can have a two-day wowgold4europe good rest. For example, people [url=http://www.gameusd.org ]gameusd[/url]can go out to enjoy themselves or get meinwowgold together with relatives and friends to talk with each storeingame other or watch interesting video tapes with the speebie whole family.
Everyone spends agamegold weekends in his ownmmofly way. Within two days, some people can relax themselves by listening to music, reading novels, or watching ogeworld films. Others perhaps are more active by playing basketball, wimming or mmorpgvip dancing. Different people have different gamesavor relaxations.
I often spend weekends withoggsale my family or my friends. Sometimes my parents take me on a visit to their old friends. Sometimesgamersell I go to the library to study or borrow some books to mmovirtex gain much knowledge. I also go to see various exhibition to broaden rpg trader my vision. An excursion to seashore or mountain resorts is my favorite way of spending weekends. Weekends are always enjoyable for me.

sell eve isk said...

Sell MMORPG Gold And Money to us to get real money!
Dear player,
OGDEAL is buying mmorpg virtual currency. We will offer high price to buy your game gold. Hot games: sell WOW gold, sell warhammer gold, sell eve online isk: www.eve-online-isk.com , sell silkroad gold, sell maple story mesos, sell lotro gold, sell lotro europe gold, sell aoc gold, sell Lineage 2 adena, sell EverQuest 2 platinum, sell FFXI gil, sell SWG credits, sell gaia gold, sell 2moons dil, sell cabal online alz, sell kalonline geons to : www.ogdeal.com .
Any questions please Contact our site’s live support chat or MSN: ogdeal@hotmail.com Thanks !

sell eve isk said...

sell wow goldsell wow gold to ustrade wow goldsell wow gold to ussell your wow gold
sell world warcraft goldsell maplestory mesossell maple story mesossell eve isk
sell eve online isk
sell isk
sell maplestory mesos
sell maple story mesos
sell mesos
sell silkroad gold
sell sro gold
Sell Final Fantasy XI Gil
sell ffxi gil
sell gaia gold
sell gaia online gold
sell lotro gold
sell lotro europe gold
sell lord of the rings online gold
Sell Lineage 2 Adena
Sell Age Of Conan gold
sell aoc gold
Sell EverQuest 2 platinum
Sell EQ2 platinum
sell GW gold
sell swg credits
sell warhammer gold
sell warhammer online gold

sell wow goldsell maple story mesossell wow gold us server
sell wow gols eu serversell maplestory mesossell guild war goldSell EverQuest 2 PlatinumSell ffxi gilSell eve online iskSell aoc goldSell aoc goldSell silkroad goldsell lineage2 Adenasell anarchy Creditssell warhammer goldsell lotro goldsell lotro gold eusell perfect world goldsell gaia goldrunescaperunescape goldbuy runescape goldrunescape moneyrs goldrunescape powerlevelingrunescape itemeve online
eve Isk
buy eve online isk
silkroad gold
buy silkroad goldsilkroad online
Anarchy Online Credits
Anarchy OnlineWarhammer GoldWarhammer OnlineFFXI GilGaia Goldperfect worldperfect world goldguild wars goldaoc goldlineage2 adenaeq2 platswg credit2moons dillotro goldeve online iskeve iskbuy eve iskbuy eve online iskcheap eve iskcheap eve online iskrunescape goldbuy runescape goldrunescape moneybuy runescape moneyrunescape goldrunescape powerlevelingrunescape moneybuy runescape moneybuying runescape moneybuying runescape goldbuying runescape moneyrunescape powerlevelingmaplestory mesosmaple story mesosbuy maplestory mesosbuy maple story mesosbuy ms mesosms mesoswow goldbuy wow goldworld of warcraft goldbuy world of warcraft goldbuying wow goldwow gold for sale

Divided Mind said...

Thanks, it's a lifesaver! Although most of apps have public source, I'm currently working on something that I'd like to look somewhat like google talk, and this isn't open source. Your tool makes it a lot easier, being able to look at the layouts... thanks a million!

tero gold said...

Good blog.

Thanks.

Runescape gold

Android app development said...

I am so happy to read your blog logic.This is one of the suitable post.Pretty post.
Android app developers