5

i was working on a android project but my laptop was formatted so i lost all code but i had a signed apk of the file on my phone .. whenever i try to use dex2jar it stops converting mid way with this error. how can i increase the heap size or is there another way out. can i decompile an apk with the key it was signed with

C:\~dex2jar>d2j-dex2jar --force
classes.dex
dex2jar classes.dex -> classes-dex2jar.jar
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at org.objectweb.asm.Type.getInternalName(Unknown Source)
    at com.googlecode.dex2jar.v3.V3ClassAdapter.searchEnclosing(V3ClassAdapt
er.java:179)
    at com.googlecode.dex2jar.v3.V3ClassAdapter.build(V3ClassAdapter.java:13
0)
    at com.googlecode.dex2jar.v3.V3ClassAdapter.visitField(V3ClassAdapter.ja
va:303)
    at com.googlecode.dex2jar.reader.DexFileReader.acceptField(DexFileReader
.java:603)
    at com.googlecode.dex2jar.reader.DexFileReader.acceptClass(DexFileReader
.java:439)
    at com.googlecode.dex2jar.reader.DexFileReader.accept(DexFileReader.java
:330)
    at com.googlecode.dex2jar.v3.Dex2jar.doTranslate(Dex2jar.java:84)
    at com.googlecode.dex2jar.v3.Dex2jar.to(Dex2jar.java:239)
    at com.googlecode.dex2jar.v3.Dex2jar.to(Dex2jar.java:230)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java
:109)
    at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:168)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:34)
Anurag Dalia
  • 156
  • 4
  • 11

2 Answers2

8

Make a copy of the d2j-dex2jar.bat file, and edit it. Find the line that says this:

java -Xms512m -Xmx1024m -cp "%CLASSPATH%" 
            "com.googlecode.dex2jar.tools.Dex2jarCmd" %*

Change the -Xmx parameter to give yourself a larger maxheap size. Save it, and see if your modified BAT file works better. (There isn't an elegant way to override the JVM settings in this script.)


Apparently ... if you are using dex2jar-2.0, the file that you need to edit is d2j_invoke.bat.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • i tried this but it gave me another error dex2jar classes.dex -> classes-dex2jar.jar # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1863680 bytes for card ta ble expansion # An error report file with more information is saved as: # C:~dex2jar-0.0.9.13\hs_err_pid6240.log – Anurag Dalia May 11 '13 at 15:11
  • 1
    You've not got enough physical memory / swap space to make the heap that large. Try something smaller. It may be that this approach won't work at all. Maybe you need to figure out why dex2jar is using so much memory, and modify it. (Maybe it is leaking memory ...) – Stephen C May 11 '13 at 23:17
  • can't find that line. @"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.Dex2jarCmd %* – Dainius Kreivys Sep 04 '16 at 16:54
3

if you use dex2jar-2.0 ,you can find the line that says this:

java -Xms512m -Xmx1024m ******************************* in d2j_invoke.bat instead of d2j_dex2jar.bat

MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57
Bravin Shi
  • 31
  • 1