alexzaitsev / apk-dependency-graph

Android class dependency visualizer. This tool helps to visualize the current state of the project.
Apache License 2.0
755 stars 70 forks source link

Index.html page is empty #60

Open girish3 opened 5 years ago

girish3 commented 5 years ago

I got the following terminal output after running the command,

Baksmaling classes.dex...
Baksmaling classes2.dex...
Baksmaling classes3.dex...
Baksmaling classes4.dex...
Analyzing dependencies...
Success! Now open index.html in your browser.

But after opening the index.html file, I can see the setting view on top right but the page is empty.

alexzaitsev commented 5 years ago

Hello @girish3 Have you modified filters/default.json? If yes - could you provide it? How do you run the script?

kuzdu commented 5 years ago

I do not think that this an issue. But I ran into the same trap. The package name must not be equal the bundle identifier. I do not know why, but I entered my bundle identifier to the filters/default.json and yeah... then the index.html is empty. Fail to me and my reading skills .. 🤷🏻‍♂️

Heavylama commented 5 years ago

There is a bug when running on Windows that could explain such behaviour.

A path filter is generated using system path delimiter. This filter is then used both for filtering folders in smali output directory (good) and for parsing found class paths when processing individual smali files (bad).

In the decompiled smali code "/" package delimiter is used thus on a Windows machine filtering out everything since the filter is using "\" system path delimiter.

Modifying the code to use separate filters for system/smali paths fixes the problem. I can imagine this bug does not appear on Linux since the separator is the same.

ArmanIzad commented 4 years ago

Having the same issue. The output generated seems to be OK, just that the dependencies is empty.

There is a bug when running on Windows that could explain such behaviour.

A path filter is generated using system path delimiter. This filter is then used both for filtering folders in smali output directory (good) and for parsing found class paths when processing individual smali files (bad).

In the decompiled smali code "/" package delimiter is used thus on a Windows machine filtering out everything since the filter is using "\" system path delimiter.

Modifying the code to use separate filters for system/smali paths fixes the problem. I can imagine this bug does not appear on Linux since the separator is the same.

Where should I modify this? Any clue?

kustraslawomir commented 4 years ago

I run into same issue.

filters.json where "a.b.c" is my applicationId and package: { "package-name": "a.b.c", "show-inner-classes": false, "ignored-classes": [".*Dagger.*", ".*Inject.*", ".*ViewBinding$", ".*Factory$", ".*_.*", "^R$", "^R\\$.*"] }

command: run.bat C:\graph\application.apk C:\graph\filters.json

result: Baksmaling classes.dex... Analyzing dependencies... Success! Now open gui/index.html in your browser.

analyzed.js: var dependencies = {links:[ ]};

kustraslawomir commented 4 years ago

Following @Heavylama comment I fixed it but changing your code from:

Main.java:

 Filter<String> pathFilter = filterProvider.makePathFilter();
        Filter<String> classFilter = filterProvider.makeClassFilter();
        SmaliAnalyzer analyzer = new SmaliAnalyzer(arguments, filters, 
                                                   pathFilter, classFilter);

to:

Filter<String> smaliPathFilter = filterProvider.makeSmaliPathFilter();
        Filter<String> classFilter = filterProvider.makeClassFilter();
        SmaliAnalyzer analyzer = new SmaliAnalyzer(arguments, filters, smaliPathFilter, classFilter);

where makeSmaliPathFilter() is:

public Filter<String> makeSmaliPathFilter() {
        String replacement = Matcher.quoteReplacement(File.separator);
        replacement = Matcher.quoteReplacement(replacement);
        String packageNameAsPath = inputFilters.getPackageName().replaceAll("/", replacement);
        String packageNameRegex = ".*" + packageNameAsPath + ".*";
        RegexFilter filter = new RegexFilter(packageNameRegex);

        return filter;
    }

Now after recompile I received correct dependencies graph.

@alexzaitsev Windows. tl;dr i replaced \. with / for smali path filter.