Coder Social home page Coder Social logo

alexzaitsev / apk-dependency-graph Goto Github PK

View Code? Open in Web Editor NEW
751.0 24.0 72.0 23.2 MB

Android class dependency visualizer. This tool helps to visualize the current state of the project.

License: Apache License 2.0

JavaScript 16.04% CSS 2.35% Java 74.92% HTML 4.28% Batchfile 0.94% Shell 1.47%
apk architecture decompile android-dependency-visualizer android smali dependency-injection apk-dependency-graph

apk-dependency-graph's Introduction

Apk Dependency Graph (ADG)

Build Status version Android Arsenal

The repo is not supported anymore

Class dependency visualizer. Only apk file is needed.
Class coupling is one of the significant code metrics that shows how easy is to change, maintain and test the code. This tool helps to view whole picture of the project.

Table of contents

Usage

Some helpful scripts are prepared for you. All you need to do is to download and unpack the latest release and type the next command in your command line:

For Windows:

run.bat full\path\to\the\apk\app-release.apk full\path\to\the\filterset.json

Where:

  • run.bat is a path to script in your local repository
  • full\path\to\the\apk\app-release.apk is a full path to the apk file you want to analize
  • full\path\to\the\filterset.json is a full path to the filterset file

The tool is provided with the default filterset. However, you're highly encouraged to customize it. Read filter instructions for the details.

For Unix:

./run.sh full/path/to/the/apk/app-release.apk full/path/to/the/filterset.json

Wait until the command finishes:

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

It will decompile your apk and create output/apk-file-name folder in the same folder where the script is. After this it will analyze the smali code and generate gui/analyzed.js file which contains all dependencies.
Now open gui/index.html in your browser and enjoy!

Compile

At least Java 8 is needed to compile and run the jar file.

Ways to compile build/jar/apk-dependency-graph.jar:

>> gradle build (Gradle 5.0 or newer)
>> gradlew build (Gradle Wrapper)

Classes will be generated to build/classes folder and jar file will appear onto build/libs folder.

To get more information please check our wiki page.

Examples

Here is the sample of good architecture with low class coupling:
Good sample

And this one looks like a spaghetti:
Good sample

Does your project look like the first or the second picture? :)

Demo

Watch demo video.

Contributors

I want to say thank you to all the people who made even tiny pull request. This project is intended to improve current state of Android architecture all over the world so each detail is important. In the contributors page you can find a list of people who have found some time to improve this tool.

Credits

There is the same tool for iOS: https://github.com/PaulTaykalo/objc-dependency-visualizer
I have used gui/index.html of that project. Thanks Paul for the great tool.

apk-dependency-graph's People

Contributors

alexzaitsev avatar martinbreuerf2m avatar supinepandora43 avatar victorrattis avatar warrenfaith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apk-dependency-graph's Issues

Index.html page is empty

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.

extentions feature

Contributors wanted
All of these changes touches mostly src module. To get better understanding of project structure please visit our wiki pages.

Why we need it?
A lot of people are asking questions like "How can I filter Dagger dependecies?". I'm interested in generalizing of this idea to the concept of extensions (or plugins) - some piece of software, written by somebody, that you can join to your main program to boost it. (Important: it should not be recompiled.)

How to do that?
I have some ideas. In very simple realization extension can be a json file with settings. User can pass it to the main program so we should add such ability also to the run scripts (unix and windows).
Another think - we should have ablitity to join multiple such files at a time. So SmaliAnalyzer will be provided by an array of rules and we should apply each rule one by one to outline the final set of classes which should be shown to the user.

This is a very brief description, you can stick to some more adult solution 👍 If you have some additions - please leave them here. If you want to implement this I would love to aswer to all your questions! Thank you.

Doesn't work with multidex

Hi,

When the multidex is enable on big app, the tool with generate multiple smali files but the analyser will only read one folder.

Lucas

Graph appears entirely blank

Hi, this tool looks neat, but I'm having some trouble with it.

I've gotten everything where it says it runs successfully, but the end result is an index.html page that has no dependency graph. I've tried nofilter/filter by apk name and two separate apks. The result always comes out the same.

Screenshot attached for clarity.

screen shot 2017-05-27 at 6 00 33 pm

I likely have something setup wrong, but I'm not sure what it is.

Error: Unable to access jarfile

Hello!
I downloaded last release. Trying to run bat (OS is Windows 10).
And have next error:

Error: Unable to access jarfile C:\Users\dGorod\Android

Maybe because my Android SDK installed not by default path?

Create scripts to publish the app for Windows, Linux and Mac

Create scripts to publish the app for Windows, Linux, and Mac.

The Objective of this issue is:

  • Create a script to build the apk-dependency-graph jar and move it to "gui/lib" directory;
  • Create scripts to package the electron app for Windows, Linux, and Mac platforms;
  • Create scripts to creates the installers for Windows, Linux, and Max;
  • Update the README.txt file with new information.

Keep getting "java.lang.IllegalArgumentException"

Hi, just tried it on 2 projects I have and I keep having the following error:

Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing
    at java.util.regex.Matcher.appendReplacement(Unknown Source)
    at java.util.regex.Matcher.replaceAll(Unknown Source)
    at java.lang.String.replaceAll(Unknown Source)
    at code.SmaliAnalyzer.run(Unknown Source)
    at code.Main.main(Unknown Source)

I thought it was due to the Greek characters I have on my first project, but the second one doesn't contain any... :/

Thanks

versioning feature

Contributors wanted
All of these changes touches mostly gui module. To get better understanding of project structure please visit our wiki pages.

Why we need it?
What I want to archieve is to create each time new analyzed.js file. Let's imagine you're working on some project that has project.apk. We're analyzing that project constantly. How to see the changes on our graph? We need to rename and keep each analyzed.js file manually. That could be boring and time ineffective.

How to do that?

  1. we need to define flexible analyzed.js name and path on the run scripts (unix and windows)
    I suggest to keep them on the separate folder named by project name. In our example that's project-analyzed folder. There we need to create a file named project-timestamp.js where project is a project name and timestamp is a current timestamp.
  2. we need to find out a way how to pass a current filename to index.html. It could be a file dialog however I'd like to have something more convenient.
  3. ideally we should provide users with clear scripts or something to manage his projects and different versions of analyzed file.

This is a very brief description, I could miss something. If you have some additions - please leave them here. If you want to implement this I would love to aswer to all your questions! Thank you.

JS files has no depencies

The process seems to run correctly however the JS file has no dependencies. This tools looks awesome but could do with some support/ideas.

var dependencies = {links:[
]};

The console produces:


I: Using Apktool 2.2.0 on app-dev-debug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /var/root/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes10.dex...
I: Baksmaling classes11.dex...
I: Baksmaling classes12.dex...
I: Baksmaling classes13.dex...
I: Baksmaling classes14.dex...
I: Baksmaling classes15.dex...
I: Baksmaling classes16.dex...
I: Baksmaling classes17.dex...
I: Baksmaling classes18.dex...
I: Baksmaling classes19.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes20.dex...
I: Baksmaling classes21.dex...
I: Baksmaling classes22.dex...
I: Baksmaling classes23.dex...
I: Baksmaling classes24.dex...
I: Baksmaling classes25.dex...
I: Baksmaling classes26.dex...
I: Baksmaling classes27.dex...
I: Baksmaling classes28.dex...
I: Baksmaling classes29.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes30.dex...
I: Baksmaling classes31.dex...
I: Baksmaling classes32.dex...
I: Baksmaling classes33.dex...
I: Baksmaling classes34.dex...
I: Baksmaling classes35.dex...
I: Baksmaling classes36.dex...
I: Baksmaling classes37.dex...
I: Baksmaling classes38.dex...
I: Baksmaling classes39.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes40.dex...
I: Baksmaling classes41.dex...
I: Baksmaling classes42.dex...
I: Baksmaling classes43.dex...
I: Baksmaling classes44.dex...
I: Baksmaling classes45.dex...
I: Baksmaling classes46.dex...
I: Baksmaling classes47.dex...
I: Baksmaling classes48.dex...
I: Baksmaling classes49.dex...
I: Baksmaling classes5.dex...
I: Baksmaling classes50.dex...
I: Baksmaling classes51.dex...
I: Baksmaling classes52.dex...
I: Baksmaling classes53.dex...
I: Baksmaling classes54.dex...
I: Baksmaling classes6.dex...
I: Baksmaling classes7.dex...
I: Baksmaling classes8.dex...
I: Baksmaling classes9.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
Success! Now open index.html in your browser.

Exception in thread "main" java.lang.NullPointerException

Trying out several release apk i get this error

at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:58) at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:516) at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:267) at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:108) at brut.apktool.Main.cmdDecode(Main.java:163) at brut.apktool.Main.main(Main.java:81)

no difference if i run sh run.sh ... or java -jar ...

Empty list of dependencies

Hello.
I'm trying to build a graph for my app, but I get an empty dependency array.

var dependencies = {links:[
]};

P.S. I'm use apktool 2.3.0.

What framework do I need in order to decompile SystemWebView.apk

I built from fresh chromium install:

I need a framework but I am not sure which one.

I used to the following apk from the Samsung S5: framework-res.apk

with the following command:

sudo apktool if framework-res.apk

I get the following output:

c@c:/usr/local/bin$ sudo apktool d SystemWebView.apk
I: Using Apktool 2.2.1 on SystemWebView.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values / XMLs... Exception in thread "main" java.lang.NullPointerException

at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:58)

at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:516)

at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:267)

at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:132)

at brut.androlib.ApkDecoder.decode(ApkDecoder.java:108)

at brut.apktool.Main.cmdDecode(Main.java:166)

at brut.apktool.Main.main(Main.java:81)

Has anyone decompiled SystemWebView.apk successfully? If so, What resource apk did they use if not framework-res.apk?

Add "exclude" filter

Most of projects have utilities classes that don't need to be presented as dependencies. It would be great to have a possibility to exclude those classes from dependency graph.

Filtering feature

  • That should be a json file with the following structure: ["regexp1", "regexp2"] and so on.
  • That files should be stored in /filters/ folder.
  • Create /filters/default.json file that should be shipped with the jar.
  • User can change filters and add new files.
  • Filtering takes place at the java code.
  • Run scripts to be changed.
  • Edit travis-ci script to ship filters in the releases.

Related to #19

Steps for development:
1. Create json file.
2. Modify Arguments.java and ArgumentReader.java:
* read file name
* read json file to array
* create final filter regexp

  • pass to SmaliAnalyzer.java
  1. Modify SmaliAnalyzer.java

New release

Hi there, last release was from last year's 28 Sep 2016. Now that we have multidex support can you please generate a new release?

Thank you very much for this tool

Is it possible to see dependencies by package?

We wanted to use the dependency graph to easier untangle and understand dependencies in order to break down our monolithic project to separate feature modules. Out project contains more than 200 screens and the visualization is unusable and slow.
Perhaps it would be more helpful to see dependencies by the package, is it possible?

It deletes project instead of output directory

There is a line in Main.java that states it deletes output dir but deletes project instead.

if (FileUtils.deleteDir(arguments.getProjectPath())) {

        // Delete the output directory for a better decoding result.
        if (FileUtils.deleteDir(arguments.getProjectPath())) {
            System.out.println("The output directory was deleted!");
        }

i gues it should be

        if (FileUtils.deleteDir(arguments.getResultPath())) {

instead

Empty report html

`\apk-dependency-graph-scripts-0.3.1>run.bat demo-debug.apk default.json

The output directory was deleted!
Baksmaling classes17.dex...
Baksmaling classes26.dex...
Baksmaling classes78.dex...
Baksmaling classes35.dex...
Baksmaling classes40.dex...
Baksmaling classes92.dex...
Baksmaling classes22.dex...
Baksmaling classes69.dex...
Baksmaling classes53.dex...
Baksmaling classes39.dex...
Baksmaling classes56.dex...
Baksmaling classes80.dex...
Baksmaling classes47.dex...
Baksmaling classes62.dex...
Baksmaling classes8.dex...
Baksmaling classes84.dex...
Baksmaling classes4.dex...
Baksmaling classes13.dex...
Baksmaling classes75.dex...
Baksmaling classes43.dex...
Baksmaling classes71.dex...
Baksmaling classes41.dex...
Baksmaling classes25.dex...
Baksmaling classes88.dex...
Baksmaling classes95.dex...
Baksmaling classes79.dex...
Baksmaling classes34.dex...
Baksmaling classes91.dex...
Baksmaling classes21.dex...
Baksmaling classes50.dex...
Baksmaling classes38.dex...
Baksmaling classes66.dex...
Baksmaling classes7.dex...
Baksmaling classes48.dex...
Baksmaling classes57.dex...
Baksmaling classes81.dex...
Baksmaling classes63.dex...
Baksmaling classes12.dex...
Baksmaling classes76.dex...
Baksmaling classes29.dex...
Baksmaling classes85.dex...
Baksmaling classes31.dex...
Baksmaling classes89.dex...
Baksmaling classes16.dex...
Baksmaling classes3.dex...
Baksmaling classes44.dex...
Baksmaling classes72.dex...
Baksmaling classes33.dex...
Baksmaling classes42.dex...
Baksmaling classes28.dex...
Baksmaling classes37.dex...
Baksmaling classes94.dex...
Baksmaling classes51.dex...
Baksmaling classes67.dex...
Baksmaling classes24.dex...
Baksmaling classes.dex...
Baksmaling classes64.dex...
Baksmaling classes6.dex...
Baksmaling classes90.dex...
Baksmaling classes11.dex...
Baksmaling classes54.dex...
Baksmaling classes82.dex...
Baksmaling classes49.dex...
Baksmaling classes60.dex...
Baksmaling classes19.dex...
Baksmaling classes15.dex...
Baksmaling classes58.dex...
Baksmaling classes2.dex...
Baksmaling classes86.dex...
Baksmaling classes73.dex...
Baksmaling classes30.dex...
Baksmaling classes45.dex...
Baksmaling classes32.dex...
Baksmaling classes27.dex...
Baksmaling classes77.dex...
Baksmaling classes68.dex...
Baksmaling classes52.dex...
Baksmaling classes36.dex...
Baksmaling classes93.dex...
Baksmaling classes23.dex...
Baksmaling classes65.dex...
Baksmaling classes10.dex...
Baksmaling classes9.dex...
Baksmaling classes20.dex...
Baksmaling classes55.dex...
Baksmaling classes83.dex...
Baksmaling classes61.dex...
Baksmaling classes5.dex...
Baksmaling classes14.dex...
Baksmaling classes70.dex...
Baksmaling classes74.dex...
Baksmaling classes46.dex...
Baksmaling classes18.dex...
Baksmaling classes59.dex...
Baksmaling classes87.dex...
Analyzing dependencies...
Success! Now open gui/index.html in your browser.`

index.html contains only settings in the top right corner but no dependency graph. default.json was updated with my package name

Workaround for various problems

For others attempting to use this project

TL;DR
Just need to do a couple of steps to use this project

  • Compile the project
  • Add package to filters json file

Make gradlew executable and build/compile the git repo e.g.

apk-dependency-graph$ chmod a+x gradlew
apk-dependency-graph$ ./gradlew build

Edit filters/default.json and add your package name (not optional!)

apk-dependency-graph/filters$ cp default.json custom.json
apk-dependency-graph/filters$ vim custom.json 

Then edit the file so it resembles:

{
    "package-name": "com.example.myproject",
    ...

Once that's done should be ready to run the command, make sure to use the copied custom.json file e.g.

apk-dependency-graph$ ./run.sh .../myproject/main/build/outputs/apk/debug/main-debug.apk filters/custom.json

Details
First, releases may not work; very likely the version the release was built against is incompatible with whatever version is on local workstation*. That error will typically resemble

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/alex_zaitsev/adg/Main 
has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version 
of the Java Runtime only recognizes class file versions up to 52.0

Also, cloning the repo won't work out-of-the-box; it will be necessary to compile in order to generate required file build/libs/apk-dependency-graph.jar, otherwise will see error typ.

Error: Unable to access jarfile .../apk-dependency-graph/build/libs/apk-dependency-graph.jar

Finally, it will be necessary to add package-name to filters/default.json otherwise will fail typ.

'package-name' option cannot be empty. Check filters/default.json

*Yes, it is possible to attempt to address the disparity by mucking around with downloading and installing various JDK versions, but that can result in strange behavior changes on workstation...

Add Zoom-in (out) functionality

It is impossible to use this tool for large projects because it creates unreadable graph: nodes are big, edges are small, adding class names just makes a mess. It would be great to have vector zooming to isolate some part of the graph which user is working with.

Add DOT support

This tool should be (and could be!) useful for developers so it's great to support engineer graph visualizer like Graphviz instead of fancy animated bubbles. At least "Export as DOT" would be great.

Lag

Hello. Great tool, but performancy(in my case at leaast) is really bad.

I opened a generated graph of a Kotlin project(which means all the generated lamdas/inner classes) on my i7 and it was unusable.

Chrome version: 66.0.3359.170

Here's a short profile session from chrome

lag.zip

NullPointerException in the analysis step

I try to use java -jar apk_dependency_graph_0.0.2.jar -i path-to-folder-with-decompiled-files -o analyzed.js -f com.example.test and I get:

    Exception in thread "main" java.lang.NullPointerException
        at code.CodeUtils.isClassInner(CodeUtils.java:14)
        at code.SmaliAnalyzer.processSmaliFile(SmaliAnalyzer.java:99)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:58)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
        at code.SmaliAnalyzer.run(SmaliAnalyzer.java:32)
        at code.Main.main(Main.java:20)

If I use the nofilter flag I get:

    Exception in thread "main" java.lang.NullPointerException
        at code.SmaliAnalyzer.isClassOk(SmaliAnalyzer.java:132)
        at code.SmaliAnalyzer.processSmaliFile(SmaliAnalyzer.java:91)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:58)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
        at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
        at code.SmaliAnalyzer.run(SmaliAnalyzer.java:32)
        at code.Main.main(Main.java:20)

java.io.IOException: org.jf.util.ExceptionWithContext: Encountered small uint that is out of range at offset 0x38

./run.sh app-debug.apk default.json
Baksmaling assets/A3AEECD8.dex...
java.io.IOException: org.jf.util.ExceptionWithContext: Encountered small uint that is out of range at offset 0x38
at com.alex_zaitsev.adg.decode.ApkSmaliDecoder.decodeDexFile(ApkSmaliDecoder.java:65)
at com.alex_zaitsev.adg.decode.ApkSmaliDecoder.decode(ApkSmaliDecoder.java:47)
at com.alex_zaitsev.adg.decode.ApkSmaliDecoderController.decode(ApkSmaliDecoderController.java:14)
at com.alex_zaitsev.adg.Main.main(Main.java:40)
Caused by: org.jf.util.ExceptionWithContext: Encountered small uint that is out of range at offset 0x38
at org.jf.dexlib2.dexbacked.BaseDexBuffer.readSmallUint(BaseDexBuffer.java:58)
at org.jf.dexlib2.dexbacked.DexBackedDexFile.(DexBackedDexFile.java:90)
at org.jf.dexlib2.dexbacked.DexBackedDexFile.(DexBackedDexFile.java:110)
at org.jf.dexlib2.dexbacked.ZipDexContainer$ZipDexFile.(ZipDexContainer.java:146)
at org.jf.dexlib2.dexbacked.ZipDexContainer.loadEntry(ZipDexContainer.java:188)
at org.jf.dexlib2.dexbacked.ZipDexContainer.getEntry(ZipDexContainer.java:115)
at org.jf.dexlib2.dexbacked.ZipDexContainer.getEntry(ZipDexContainer.java:58)
at org.jf.dexlib2.DexFileFactory$DexEntryFinder.findEntry(DexFileFactory.java:382)
at org.jf.dexlib2.DexFileFactory.loadDexEntry(DexFileFactory.java:186)
at com.alex_zaitsev.adg.decode.ApkSmaliDecoder.loadDexFile(ApkSmaliDecoder.java:101)
at com.alex_zaitsev.adg.decode.ApkSmaliDecoder.decodeDexFile(ApkSmaliDecoder.java:57)
... 3 more
Analyzing dependencies...
/Users/songwei/workspace/工具/sdk依赖关系/apk-dependency-graph-scripts-0.3.1/output/app-debug does not exist!

Exception in thread "main" java.lang.UnsupportedClassVersionError

Hi, thank you for your lib. I wanted to check my project with it but ./run.sh give that crash

$ ./run.sh /home/anduser/Andersen/Learning/Archit cture/app/build/outputs/apk/debug/app-debug.apk com.mvisample true
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: code/Main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

I have compile oprions in build.gradle

compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }

The same is occurring for other project also. I have tried to change JDK location in my Android Studio to not embeded one but with new build I get the same error

$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

I have also tried plugin for Android Studio, but after first graph generation (it was empty) now clicking on Generate Graph button make Android Studio to close itself

UPDATE
Have checked it with version 0.1.3 and everything works fine (in 0.1.4 jar is missing so also working). Does it mean that to work with 0.1.5 version I need to decompile jar with 1.8 java ?

Graph generation broken in 0.2.0+

Firstly, thanks for your hard work developing this tool. It is a great resource for laying the groundwork of our refactoring project.

I've noticed that the graphs generated in the latest version 0.3.1 don't provide any useful information. I've noted a couple issues:

  1. Graphs do not show any class dependencies, but rather showcase function dependencies for each class (see representative sample below, I don't want to disclose too much but all my classes look something like this)
    image

  2. The generated analyzed.js file seems to be missing a whole bunch of classes (namely Activities)

My filters are defined as:

{
    "package-name": "[REDACTED]",
    "show-inner-classes": true, // if I set this to false, I wouldn't see anything generated in index.html or analyzed.js 
    "ignored-classes": [".*Dagger.*", ".*Inject.*", ".*ViewBinding$", ".*Factory$", ".*_.*", "^R$", "^R\\$.*"]
}

I'm running on a Windows 10 machine.

I really want to use this tool, and was wondering why the generated outputs differ widely from your screenshots, so I thought it might have broken in an update. Fortunately, I was able to generate the expected graphs using an older version 0.1.5. This seems to resolve the above 2 issues. All versions after 0.1.5 somehow broke the output.

That said, the filtering options available in 0.3.1 are super helpful, and I wish I was able to integrate those back into 0.1.5 since 0.1.5 is the latest version that somehow works properly. but for the time being, what I have generated using 0.1.5 is a great start.

Let me know if you need me to provide more info to help debug this issue. Thanks again!

NullPointerException when decoding values */* XMLs ...

W: Cant find 9patch chunk in file: "drawable-hdpi-v4/orca_composer_top_divider.9.png". Renaming it to *.png.
W: Cant find 9patch chunk in file: "drawable-tvdpi-v4/common_plus_signin_btn_text_light_normal.9.png". Renaming it to *.png.
W: Cant find 9patch chunk in file: "drawable-hdpi-v4/orca_composer_tab_dark.9.png". Renaming it to *.png.
W: Cant find 9patch chunk in file: "drawable-tvdpi-v4/common_google_signin_btn_icon_dark_pressed.9.png". Renaming it to *.png.
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.NullPointerException
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:58)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:516)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:267)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:108)
        at brut.apktool.Main.cmdDecode(Main.java:163)
        at brut.apktool.Main.main(Main.java:81)
Please check your filter!

[IMPROVEMENT] Remove apktool dependency and use baksmali to decode an APK file.

Currently, apktool lib is used to decode an APK file into smali code, and its jar is added directly in the project and for each update in the jar is done the repository size increases (today, the repository size is ~23MB).

Also, apktool does more than decode an APK in smali code:

I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\username\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values / XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

and only using the baksmali is better because it just decodes the classes.dex to smali code.

Tasks:

  • Remove the apktool jar file of the project;
  • Use the baksmali lib to decode an APK;
  • Use ivy apache to download and manager the baksmali dependency on the project;
  • Implement a solution to use the baksmali lib in the project to decode an APK.

Can't get it to work, tried with multiple APKs

Tried with serveral different APKs. It builds and runs fine, but the analyzed.js is always:

var dependencies = {links:[
]};

I tried the current master as well as the dev branch, same results.
Tried with 2 different application APKs.

[UI] Remember the previous values inserted by the user

Remember the previous values inserted by the user for the fields: "APK file path", "filter" and "show inner classes".

"The purpose is to make easier to play with the same APK - preview the graph with the different filter or without a filter, or play with inner classes. Now I have to drag APK each time to rebuild the graph so I think this can be improved."

Exception during "Copying original files...": "java.lang.StringIndexOutOfBoundsException: String index out of range"

Cool idea for a tool!

I just heard it and thought I'd give it a go with my app. I'm seeing a StringIndexOutOfBoundsException in the Copying original files... step.

/run.sh [path to android-debug.apk] [my package name]
I: Using Apktool 2.2.0 on android-debug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/jason/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -36
    at java.lang.String.substring(String.java:1955)
    at code.SmaliAnalyzer.parseAndAddClassNames(SmaliAnalyzer.java:150)
    at code.SmaliAnalyzer.parseAndAddClassNames(SmaliAnalyzer.java:151)
    at code.SmaliAnalyzer.processSmaliFile(SmaliAnalyzer.java:85)
    at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:58)
    at code.SmaliAnalyzer.traverseSmaliCode(SmaliAnalyzer.java:61)
    at code.SmaliAnalyzer.run(SmaliAnalyzer.java:32)
    at code.Main.main(Main.java:20)

Here's some more info about my environment:

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

OS X El Capitan 10.11.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.