apk-dependency-graph icon indicating copy to clipboard operation
apk-dependency-graph copied to clipboard

Index.html page is empty

Open girish3 opened this issue 5 years ago • 6 comments

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.

girish3 avatar Sep 05 '19 03:09 girish3

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

alexzaitsev avatar Sep 05 '19 06:09 alexzaitsev

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 .. 🤷🏻‍♂️

kuzdu avatar Sep 13 '19 09:09 kuzdu

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.

Heavylama avatar Oct 20 '19 14:10 Heavylama

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?

ArmanIzad avatar Dec 04 '19 17:12 ArmanIzad

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 avatar Dec 13 '19 15:12 kustraslawomir

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.

kustraslawomir avatar Dec 13 '19 15:12 kustraslawomir