Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java heap size error dex2jar android decompile solution?

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)
like image 769
Anurag Dalia Avatar asked Jan 14 '23 09:01

Anurag Dalia


1 Answers

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.

like image 118
Stephen C Avatar answered Feb 01 '23 07:02

Stephen C