Android – Reverse engineering from an APK file to a project

androidapkdecompiling

I accidently erased my project from Eclipse, and all I have left is the APK file which I transferred to my phone. Is there a way to reverse the process of exporting an application to the .apk file, so I can get my project back?

Best Answer

There are two useful tools which will generate Java code (rough but good enough) from an unknown APK file.

  1. Download dex2jar tool from dex2jar.

  2. Use the tool to convert the APK file to JAR: Windows:

     $ d2j-dex2jar.bat demo.apk
     dex2jar demo.apk -> ./demo-dex2jar.jar
    

    MacOS / Linux:

     $ d2j-dex2jar.sh -f demo.apk -o demo.jar
    
  3. Once the JAR file is generated, use JD-GUI to open the JAR file. You will see the Java files.

The output will be similar to:

JD GUI

Then you can use other tools to retrieve the AndroidManifest.xml and resource files (like images, translations, etc...) from the APK file.

  • Apktool

     $ java -jar apktool.jar -q decode -f demo.apk -o outputDir
    
  • AXMLParser

     $ apkinfo demo.apk
    
  • NinjaDroid

     $ ninjadroid demo.apk --all --extract