Friday, February 25, 2011

.dex format to .jar format

Now very easy to convert the .apk file to ordinary java file before going that we should want two jar files

1. JD-GUI.zip
2. dex2jar.zip
3.Eclipse

Download that two zip files extract and store in your local directory....

      Steps to extract the .dex to .jar

Step 1 : Now You just create one java project in eclipse like the following.....



Step 2: Right click the project --> Select build path --> then configure build path
             one  window appear  like

        
Step 3 : Now select Add external JARs option --> browse upto dex2jar lib directory select all jar files -->            
             Click OK
             Ensure all jar are added or not
        

Step 4 : Now copy the .apk file and paste into the project


               Check the folder structure  should look like above

Step 5: Now you want to configure
            Right click the project ---> Select Run As  --> Then Select Run Configurations...
            one window show like

            On that window select Java Application Option which is placed in left side menu.
          
Step 6 : Then Enter  this one in pxb.android.dex2jar.v3.Main Main Class Text box
        


 Step 7: select Argument tab Enter the Apk name with .apk extension in Program arguments text field
        
Step 8 : Click Apply and Run


     U just go and check in console It will give result like this.

              
                                      
  Now refresh the Java project one new file created with the name of  (xxx.apk.dex2jar.jar) copy that file and then paste to your local drive




Step  to convert .jar file to ordinary class file

 Now you go to Jd-gui tools select xxx.apk.dex2jar.jar file
          
              It will show like

            

Now you got ordinary java file from .dex file...
          


             

38 comments:

  1. Hey i am getting an error while converting to jar, can you check this?


    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

    ReplyDelete
  2. Hey santhu., Check your compilation jre and & running jre it should be same

    ReplyDelete
  3. Think you very much for this help.

    ReplyDelete
  4. Great guide!

    If "pxb.android.dex2jar.v3.Main" does not work, press search and type Main. Then you will find the correct one. On my system I used "com.googlecode.dex2jar.v3.Main".

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. " Now refresh the Java project one new file created with the name of (xxx.apk.dex2jar.jar) copy that file and then paste to your local drive"

    i cannot get the rosie.apk.dex2jar.jar to show up. any ideas?

    ReplyDelete
  7. hi all,even thou i changed t main class to com.googlecode.dex2jar.v3.Main i still get error as cannot find main class
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"

    suggest me a solution

    ReplyDelete
  8. i get this exception while i running
    Exception in thread "main" java.lang.NoClassDefFoundError: pxb/android/dex2jar/v3/Main

    ReplyDelete
  9. ty, it works! just that pxb.android.dex2jar.v3.Main has to become: com.googlecode.dex2jar.v3.Main

    ReplyDelete
  10. Hi,

    I tried as the guide is given, but i got java.lang.NoClassDefFoundError: com/googlecode/dex2jar/v3/Main error, when i search for the Main Class it says no record found, Any help/suggestion please.

    ReplyDelete
  11. Hi there,

    I got the below exception:

    0 [main] INFO com.googlecode.dex2jar.v3.Main - version:0.0.7.10-SNAPSHOT
    16 [main] INFO com.googlecode.dex2jar.v3.Main - dex2jar Autotextreply.apk -> Autotextreply.apk.dex2jar.jar
    47 [main] ERROR com.googlecode.dex2jar.v3.Main - . while process file: [Autotextreply.apk]
    47 [main] ERROR com.googlecode.dex2jar.v3.Main - .. ROOT cause:
    java.util.zip.ZipException: unexpected EOF
    at java.util.zip.ZipInputStream.read(Unknown Source)
    at java.util.zip.ZipInputStream.closeEntry(Unknown Source)
    at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
    at com.googlecode.dex2jar.v3.Main.doFile(Main.java:144)
    at com.googlecode.dex2jar.v3.Main.main(Main.java:89)
    47 [main] INFO com.googlecode.dex2jar.v3.Main - Done.

    What to do?

    ReplyDelete
  12. APK was not build in project even after pasting in workSpace ... I never saw it ever there . So is this some other eclipse ?

    ReplyDelete
  13. how to revert back from jar to dex?

    ReplyDelete
  14. Hi,
    For this to work we need to install jdk version 1.6 and above.

    ReplyDelete
  15. Excellent tool ..just a small correction in the instructions .. looks like the Main class has changed to this .. com.googlecode.dex2jar.v3.Main

    ReplyDelete
  16. Excellent tool ..just a small correction though ..looks like the Main class has changed to com.googlecode.dex2jar.v3.Main

    ReplyDelete
  17. Hey dude..!

    Exception in thread "main" java.lang.NoClassDefFoundError: pxb/android/dex2jar/v3/Main
    Caused by: java.lang.ClassNotFoundException: pxb.android.dex2jar.v3.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    Could not find the main class: pxb.android.dex2jar.v3.Main. Program will exit.

    This is what i got.! though I have imported the jar files

    ReplyDelete
  18. Hi dude,

    This is what i got, Though i have imported the jar files.


    Exception in thread "main" java.lang.NoClassDefFoundError: pxb/android/dex2jar/v3/Main
    Caused by: java.lang.ClassNotFoundException: pxb.android.dex2jar.v3.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    Could not find the main class: pxb.android.dex2jar.v3.Main. Program will exit.

    ReplyDelete
  19. Nice tutorial.............Thanks.......

    ReplyDelete
  20. Nice Tutorial..................Thanks...

    ReplyDelete
  21. Thank you very much. Very useful and easy-to-understand tutorial

    ReplyDelete
  22. Thanks a lot. It helped me very much.

    ReplyDelete
  23. It's good tutorial... can you also show how to check layouts as well?

    ReplyDelete
  24. Thank you very much, works great and is very useful.

    ReplyDelete