32

I am trying to reverse engineer an existing android app and understand how a particular UI is constructed. I've found that I can rename the apk to zip and view some of the compiled source. The res/layout directory is populated with all the xml files that define the UI, but while they do have the xml extension, they are not in XML format. Is there anyway to convert these files back to text based markup?

nolan
  • 480
  • 1
  • 7
  • 14
  • What exactly are you trying to reverse engineer? If this is someone's commercial product, you shouldn't be messing with it. If its open source you should go to the project itself to look at the code. Designing xml layouts aren't that complicated in any case... why don't you just ask "how do I create layout that looks like X" instead? – Charles B Oct 06 '10 at 00:46
  • That clarification is useful. Perhaps it might be a good idea to post a question on how to deal with this high res issue as well (or instead of this one). Someone likely knows how to fix this if there are a number of apps that display with no problem. Also I'd still advise a little caution on reverse engineering questions. Just because your intentions are pure doesn't mean subsequent readers will be the same. – Charles B Oct 06 '10 at 01:18
  • It's faster and more accurate to look into another's XML design then post a Q here and hope someone will guess. I always first look into other's XML file and then ask "how to improve it". "Hacking" into XML files is not bad at all (I would not mind to break my XML files). Hacking into Java logic is a bad and immoral thing. – sandalone Mar 04 '11 at 10:20
  • similar to http://stackoverflow.com/questions/2097813/how-to-parse-the-androidmanifest-xml-file-inside-an-apk-package – Paul Verest Dec 31 '14 at 09:19

5 Answers5

40

I think you can use android-apktool. The XML files look very well.

Kaushik NP
  • 6,733
  • 9
  • 31
  • 60
pengwang
  • 19,536
  • 34
  • 119
  • 168
6

Create a new folder and put the .apk file which you want to decode into that.

Download the latest version of from here.

Open cmd then navigate to the root directory of APKtool and type the following command:

apktool d myApp.apk 

(where myApp.apk is the filename that you want to decode)

now you get a file folder in that folder and can easily read the apk's xml files.

Here is the link for more detail install instructions

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
2

For those Who are shortcut lovers: and using ubunto,

go to cmd : ctl+alt+t

type:

sudo apt install apktool

press enter then go to your apk(to decompile) folder. by using

cd ~/folder_name

then type:

apktool d yourAppName.apk

and boom , you are done.

0

First covert your .apk to .zip. Inside that you will get a compiled-bundled version of java class files called .dex. apply the below trick to convert that dex to class files

There's a way to do this. A slight atypical way is to download this opensource tool dextojar http://code.google.com/p/dex2jar/

This will convert your dex files to Jar file. Unjar these files to get java class files.

Then reverse engineer the java class files to get the java code. Don't use it to break some commercial projects.

Thanks

Community
  • 1
  • 1
success_anil
  • 3,659
  • 3
  • 27
  • 31
  • Useful info, I am looking for the xml files tho, not the java classes. – nolan Oct 06 '10 at 14:06
  • this method is not supported now, do you know any other method than apktool to get the xml files. – Sandeep Londhe Aug 18 '15 at 17:21
  • Downvoted because this does not answer the question. The question specifically asks about the XML inside APKs, which is in a non-textual format. The correct answer (using android-apktool) does allow recovery of these files, but simply changing the name to a zip does not. Using `dextojar` is useful but does not contribute to answering the question asked. – Kristopher Micinski Mar 09 '16 at 16:57
  • Downvoted for not answering the question. Please read the question in future. – Hack5 Oct 18 '17 at 15:33
-2

if you just want to know the UI construction ,you can use Hierarchy Viewer

xesam
  • 5
  • 1