How To Modify .apk Files

The extension Google uses for Android applications  (APK) may seem a bit complicated at first, but it really isn’t. In fact, an .apk is nothing else than a .zip file disguised as an .apk. That’s dumbing it down, but you get it. Essentially, if one wanted to see what’s inside an app, they would just change the extension of applicationname.apk to applicationname.zip, unzip it.  And there you have it: The contents of the .apk!  We aren’t done yet, read more after the break.

Here is where it gets tricky. Inside the folder where you unzipped the contents of the application, you’ll find a file named classes.dex. That’s the most important file of the whole application, containing all the java files, but it’s encrypted!  No worries, that can easily be solved. You’ll need two things:

  1. Dex2Jar from http://code.google.com/p/dex2jar/
  2. A regular Java decompiler, such as JD from http://java.decompiler.free.fr

Copy classes.dex to the folder where you unzipped Dex2Jar, and run from the commandline: “dex2jar.bat classes.dex”

This will produce a file, strangely named something like: “classes.dex.dex2jar.jar” If you have WinRAR installed, you can just unpack the files. If you don’t, install it.

Now go ahead and adjust it to your liking!

[Thanks Web Age for the Dex2Jar hint]

About author

Thijs Koot
Thijs Koot 134 posts

If you see a scratched phone running an unfamiliar looking Android version, you know it's Thijs. Apart from breaking and fixing phones, he loves to play the guitar as well.

You might also like

News and Rumors

Sprint Recommends Apps for Memorial Day Travelers

Sprint is doing their part to make Android handset owners aware of apps that can benefit them come Memorial Day.  If you plan to do any traveling or cooking out,

News and Rumors

GameStop to sell Cricket Wireless starting in October

GameStop and Cricket Wireless have announced that the gaming-centric retail chain will begin selling no-contract wireless service starting next month. Expected to roll out in phases with completion by the end of

News and Rumors

Galaxy S 4 Zoom caught on camera! Get it?

  Finally we’re getting a definitely look at a stock image of the Galaxy S 4 Zoom. From the specs we’re seeing, though it would seem more appropriate to dub

18 Comments

  1. wootroot
    December 23, 16:38 Reply

    “but it really isn’t. In fact, an .apk is nothing else than a .zip file disguised as an .apk. ”

    lol..

  2. Wilbur J Farnsworth
    December 23, 16:39 Reply

    Awesome! Now I can steal code, and defeat the Market’s verification server. Thanks AndroidGuys!

    • Thijs Koot
      December 23, 16:47 Reply

      You can. That’s the illegal part. The article is the legal part.

    • appelflap
      December 23, 18:15 Reply

      Yeah, but I don’t think algorithms in an average app are that difficult. A more easy way than trying to read cryptic decompiled Java code is to investigate the well documented SDK (sssssssst don’t tell anyone :D

    • Artem Russakovskii
      June 14, 05:34 Reply

      If you were going to do that, you’d be able to figure it out without AndroidGuys. There are plenty of reasons to modify apk files other than piracy.

  3. Dave
    December 23, 18:35 Reply

    Err… don’t you think you should mention apktool and baksmali first? And how about the need to understand machine code? Poor article.

    • Brendan Tobolaski
      December 23, 22:32 Reply

      yeah… apktool is much better than the method discussed above. Simply apktool d file.apk to unpack it then apktool b file.

  4. Michael
    December 24, 10:37 Reply

    You don’t need to change the extension from .apk to .zip; 7zip will open up APK files natively!

  5. iPaulPro
    December 24, 12:05 Reply

    Hey, AndroidGuys, how about an article that explains how to download movies via torrents? Or maybe one that shows how to rig your house’s electricity meter?

    • Artem Russakovskii
      June 14, 05:33 Reply

      What the hell? So modifying an apk is now a crime or something? Maybe rooting your phone is a crime too, eh?

  6. Lakshmikanth
    February 03, 08:18 Reply

    I am getting error if i type “dex2jar.bat classes.dex”, can anyone help with what are the pre-requisties to run this perfectly.

    • pcuv1
      February 14, 20:34 Reply

      I need help too. for mac.

  7. Dragonflame54
    April 01, 11:29 Reply

    How do we use the command line of “dex2jar.bat classes.dex”

  8. azmat ali
    September 22, 09:59 Reply

    1. open .apk file in winrar
    2. drag “classes.dex” in that folder where you have “dex2jar.bat”.
    3. DRAG you classes.dex onto dex2jar.bat lets see after few second you will get “classesdex2jar.jar” there in same dir.
    4. then open program. jd-gui.exe>File>open file>select “classesdex2jar.jar”
    5. then click again (File>save all source) in the menu of “jd-gui.exe”then all source pack in a zip folder you can extract and use those in eclipse projects

    • arpa
      June 25, 06:15 Reply

      hi

      i have win 8

      when i dragclasses.dex to dex2jar.bat a black win comes one second but nothing happens after it
      no file created
      now what?

    • Steve
      September 09, 06:01 Reply

      I tried your steps but step 5 results in jd-gui freezing… Any ideas?

Leave a Reply