Git Product home page Git Product logo

depanplugin's Introduction

This is a gradle plugin to extract the bytecode informatioin of classes & fields & methods, and dependencies between them in your Android project. And save to a sqlite database file.

It's inspried by the Google's depan project.

Database structure

There is a type table to save all type (class and interface) names:

Column Description
id ID of this type
name Name of this type
access_flags The access flags of this element, see the Opcodes.java in project ASM for more details.
Note that 0x800000 means this element was skipped in the analysis, or is missing in the apk/aar.

A field table to save all fields of all classes:

Column Description
id ID of this field
name Name of this field
type ID of this field's type
owner ID of this field's owner type
access_flags The access flags of this element
string_id Internal use only

A method table to save all methods of all classes:

Column Description
id ID of this method
name Name of this method
desc Description of this method, such as (Ljava/lang/String)V
owner ID of this method's owner type
access_flags The access flags of this element
string_id Internal use only

And lastly there is a reference table to save references between all types, fields and methods:

Column Description
id ID of this method
from_sort Sort of this reference's source, can be 0(Type), 1(Field) or 2(Method)
from_id ID of this reference's source
to_sort Sort of this reference's target
to_id ID of this reference's target
relation Relation of this reference. See next paragraph for details.
string_id Internal use only

Take A references B for example, the relation of this reference can be:

Relation Description
0 Type to Type, means A extends B or A implements B
1 Field/Method to Type, means The type of A is B or A uses type B
2 Method to Field/Method, means Method A access filed B or Method A calls method B
3 Type/Field/Method to Type, means A is annotated with B

Usage

The ${lastest-version} of this plugin is . Copy below code to the build.gradle of your android application (or library) project.

buildscript {
    repositories {
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath "com.github.nekocode:DepAnPlugin:${lastest-verion}"
    }
}

apply plugin: 'depan'
 
depan {
    outputDirFile = new File(project.buildDir, "depan")
//  enabled = true
    typeFilter { typeName ->
        typeName.startsWith("cn.nekocode.depan.example") &&
                !typeName.endsWith(".R") &&
                !typeName.contains(".R\$") &&
                !typeName.contains(".databinding.") &&
                !typeName.endsWith(".BR")
    }
}

Then, you will get a sqlite database file named ${buildType}.db in the specified outputDir when you run the corresponding assemble${buildType} Task.

Now, you can query this database file by any sqlite client:

query_result

depanplugin's People

Contributors

nekocode avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.