skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.81k stars 4.88k forks source link

decompiling APK using JadxDecompiler class (jadx library) #1759

Closed XingYuanWei closed 1 year ago

XingYuanWei commented 1 year ago

thanks for you . I have a question. i use jadx as lib in java intellij idea project.as follow code.

import jadx.api.JadxArgs;
import jadx.api.JadxDecompiler;
import jadx.api.JavaClass;
import jadx.api.JavaMethod;

import java.io.File;
public class DecompilationAPk {
    public static void main(String[] args) {
        // this is apk path
        String testApkPath = "E:\\smallData\\malware\\000a067df9235aea987cd1e6b7768bcc1053e640b267c5b1f0deefc18be5dbe1";
        JadxArgs jadxArgs = new JadxArgs();
        jadxArgs.setInputFile(new File(testApkPath));
        jadxArgs.setOutDir(new File("output"));
        try (JadxDecompiler jadx = new JadxDecompiler(jadxArgs)) {
//            jadx.load();
//            jadx.save();
            System.out.println(jadx.getClasses());
            System.out.println(jadx.getPackages());
            for (JavaClass cls : jadx.getClasses()) {
                for (JavaMethod mth : cls.getMethods()) {
                    System.out.println(mth.getName());
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

i output the jadx.getClasses() but the result is empty. as follow [] [] last but not least.the decompilation source directory on can find R.java. I change other apk files, but the result always Only R.java image

jpstotz commented 1 year ago

Instead of posting screen shots it may be better to post your source code as text. Best would be a minimal code snippet that can be executed (no external dependencies except jadx libs).

skylot commented 1 year ago

@XingYuanWei you must invoke jadx.load() before accessing any jadx data.

XingYuanWei commented 1 year ago

so sorry. i will change my post question as soon as in free time.

---Original--- From: "Jan @.> Date: Fri, Jan 13, 2023 16:12 PM To: @.>; Cc: @.**@.>; Subject: Re: [skylot/jadx] [core] (Issue #1759)

Instead of posting screen shots it may be better to post your source code as text. Best would be a minimal code snippet that can be executed (no external dependencies except jadx libs).

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

XingYuanWei commented 1 year ago

hi. i change my post

---Original--- From: "Jan @.> Date: Fri, Jan 13, 2023 16:12 PM To: @.>; Cc: @.**@.>; Subject: Re: [skylot/jadx] [core] (Issue #1759)

Instead of posting screen shots it may be better to post your source code as text. Best would be a minimal code snippet that can be executed (no external dependencies except jadx libs).

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>