Batch File Decompiles Android apk to Java Source With a Single Command

This batch file decompiles an apk to its corresponding java sources. People who are looking forward to do a code review on an android app who’s source code is not readily available can utilize this bat. This batch runs various free tools available on the internet in a sequence to obtain the java source files.

This is not made to encourage piracy/plagiarism in any case.

How To

1. Extract batch file and lib folder to C:\apk2java\ (or any folder that doesnt have space in its path)

2. Backup the target app’s apk from phone to PC via ASTRO Browser (check this post for details)

3. Keep the target apk in the root folder where batch file is present

Copy target apk to exec folder

4. Run ‘apk2java.bat target.apk’ in cmd

c:\apk2java>apk2java.bat target.apk

Execute Command

Process Complete

5. Result : java and resource files available in ‘src’

src folder containing decompiled files

Note: This batch just automates the sequence in which various tools are initiated and does not handle any error events. You will have to go through the cmd verbose to figure out the problem.

Note 2: ‘lib’ folder contains apk-tool files (apk-tool.jar, aapt.exe), jad.exe, 7zip (7za.exe), dex2jar files (all other jars).  If required, update each of those tools by replacing it with latest copy from links mentioned below.

Requirements

  • Windows (but can be ported to *NIX)
  • JRE 1.6 (Java Runtime Environment)

Tools in lib

  • Dex2jar – Converts Android dex format to jar (link)
  • JAD – Java Decompiler CLI (link)
  • 7Zip – Unarchival  (link)
  • apk-tool – Extracts resources from apk (link)
  • aapt – Android Asset Packaging Tool (link)
  • aapt commands (link)

[snipt code="00aea84a3ffd7b7b8150241c20727adf"]

apk2java Info
App Name apk2java
License free
Type code
App URL Download
More Info link
  • guest
    • http://a4apphack.com/ Rajiv Vishwa

      Link is updated.. sorry about that…

      • guest

        thanks! very useful! :-)

        • Sreekhannaya

          Hi Rajiv

          I am new to Android apps… I tried the apk2java batch file for decompiling..it shows as completed but the (src) folder is empty…

          the screenshot of that is as follows…

          can you help as where am I going wrong???

          thanks in advance..
          looking forward for your reply….

          • http://a4apphack.com/ Rajiv Vishwa

            Can you please scroll up through the command prompt and check if there are any errors. It looks like the conversion of apk to dex format which is the first step in the batch process did not happen properly. And also make sure java is installed and working fine on your machine (Type ‘java -version’ in command prompt to verify)

          • guest

            Hi Rajiv

            thank u for the reply, I have checked the java -version and the conversion but I could not trace the error…the conversion is not working….attached are the screen shots of the cmd.execution…
            please do refer and suggest an solution….thank U once again…

          • http://a4apphack.com/ Rajiv Vishwa

            Hi , it looks like xcopy is not present on your system.  Try to access cmd and execute ‘xcopy’ command. Can you also try on any of your friends system and check if its working.

          • Androidblogging

            How to convert jar.jave to dex? 
            And the decoding done by apk2java is’nt humam understadable  and i see lot .java files.

  • Mahi4096

    Plz help to get res folder. I complted Full operation of the above things but in my src folder i get the com nd other folders. In that other folder is empty.

    Plz give reply

    • http://a4apphack.com/ Rajiv Vishwa

      Try using apk tool directly to extract resources.. As per the developer, apk-tool can help you extract the resources to its original form (http://code.google.com/p/android-apktool/)

      • Mahi4096

        site is nt found

      • Mahi4096

        site is nt found

      • Mahi4096

        Here we use command prompt  or any other?

  • Alex Ramos

    not possible work in any apk in folder? example: apk2java nameapk.apk —- executing only the bacth file apk2java the program work in any archive.apk ?

  • Felicity Merriman

    Does this give out code that can be recompiled?

    • http://a4apphack.com/ Rajiv Vishwa

      This is like any other decompiler app.. which means you wont be able to directly recompile to a running app again. But you can read through the code and understand the logic.

  • Pingback: root/jailbreak torch using dingleberry? - Page 2 - BlackBerry Forums at CrackBerry.com

  • Atanas Neshkov

    AndroChef Java Decompiler successfully decompiles obfuscated Java 6 and Java 7 .class and .jar files. It allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source:  http://www.neshkov.com/ac_decompiler.html

  • http://www.ijiami.cn/ Old Scholars

    http://www.ijiami.cn

    The is China doing Android app source protection.

    Can you to crack the encryption the Android APP?

    ijiami—爱加密

  • http://www.ijiami.cn/ Old Scholars

    http://www.ijiami.cn

    The is China doing Android app source protection.

    Can you to crack the encryption the Android APP?

    ijiami—爱加密