Skip to content
pxb1988 edited this page Nov 12, 2014 · 3 revisions

[TOC]

FAQ

Is dex2jar a dex decompiler

No, dex2jar is a tool for converting Android's .dex format to Java's .class format. just one binary format to another binary format, not to source.

How to decompile a dex file

See the User Guide

Got OutOfMemoryError: Java heap space

In version 0.0.7.8 and before, dex2jar use the default memory size of JVM. To translate A dex file that contains very large instruction size will cause the Error. try to add -Xms512m -Xmx1024m to dex2jar.bat or dex2jar.sh

java -Xms512m -Xmx1024m -cp "%CLASSPATH%" pxb.android.dex2jar.v3.Main %*

Want to modify a apk/dex file

the d2j-smali/d2j-baksmali have the same function with smali/baksmali.

# disassemble the dex to smali files
d2j-baksmali.sh abc.apk
# assemble smali files to dex
d2j-smali.sh out -o classes.dex

dex2jar also support modify a dex/apk file after it convert to .class file. Here is an Example how to modify a apk file with dex-tools.

alternatives:smali/baksmali,asmdex,dexmaker, they are excellent tools work with dex/odex directly, you should give it a try.

Want to read dex file using dex2jar

DexFileReader r = new DexFileReader(...);
DexFileNode n = new DexFileNode();
DexFileWriter w = new DexFileWriter();
// reade dex to DexFileNode
r.accept(n);
... // modify DexFileNode here
// copy modified DexFileNode to DexWiter
n.accept(w);
byte[] data = w.toByteArray();
... // save data

Build dex2jar from source

See the How to buid dex2jar from source

Got UnsupportedClassVersionError: Bad version n

Please check the version of jdk:

  1. dex2jar-0.0.9.x require jdk6+
  2. dex2jar-2.x require jdk7+

How can I get the nightly build of dex2jar

dex2jar host an CI server on cloudbees, you can get the nightly here: https://dex2jar.ci.cloudbees.com/job/dex2jar-2.x/lastStableBuild/com.googlecode.dex2jar$dex-tools/

How to convert jar to dex

the dx tool from android sdk can do the job

dx --dex --output=classes.dex abc.jar

and the [d2j-jar2dex] from dex2jar also can do the job

d2j-jar2dex.sh --output=classes.dex abc.jar