pxb1988 / dex2jar

Tools to work with android .dex and java .class files
Apache License 2.0
12.2k stars 2.1k forks source link

How to use it as a java lib? #113

Open ganyao114 opened 7 years ago

ganyao114 commented 7 years ago

same to the title, How can i use it as a java lib in my java application?

rightm commented 7 years ago

unzip the dex2jar-2.1-SNAPSHOT.zip if you just download from sourceforge or build youself (https://github.com/pxb1988/dex2jar/wiki/BuildFromSource). there will be many .sh or .bat files .if you want to use dex2jar.bat ,then you can use that like below in your code

public static void main(String[] args) {
    String[] params = new String[3] ;
    String dexFilePath = "G:\\deleted\\apktool\\aaa" ;
    String out = "G:\\deleted\\apktool\\aaa\\classes.jar" ;
    params[0] = dexFilePath+File.separatorChar+dexSuffix ;
    params[1] = "-o";
    params[2] = out;

    System.out.println( params[0] );
    Dex2jarCmd.main(params);
}

Don't forget add all the jars into your java lib. There will be many problems which i met "java.lang.RuntimeException: can not merge L and F" in linux . It will be ok in windows but also have some exceptions when change dex to jar