https://github.com/nekocode/depanplugin
A gradle plugin to extract the bytecode and dependency information (between classes, fields and methods) of your Android project.
https://github.com/nekocode/depanplugin
android gradle-plugin
Last synced: 3 months ago
JSON representation
A gradle plugin to extract the bytecode and dependency information (between classes, fields and methods) of your Android project.
- Host: GitHub
- URL: https://github.com/nekocode/depanplugin
- Owner: nekocode
- License: apache-2.0
- Created: 2018-10-26T19:08:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-22T09:44:18.000Z (over 6 years ago)
- Last Synced: 2025-02-09T13:31:37.646Z (5 months ago)
- Topics: android, gradle-plugin
- Language: Kotlin
- Homepage:
- Size: 345 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](https://github.com/google/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`](https://gitlab.ow2.org/asm/asm/blob/ASM_6_0/src/org/objectweb/asm/Opcodes.java#L64-88) 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 [](https://jitpack.io/#nekocode/DepAnPlugin). Copy below code to the `build.gradle` of your android application (or library) project.
```gradle
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:
