-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Jadx plugins guide
Jadx plugins system allows customizing decompilation process to:
- add custom rename policies
- custom code modifications (decryption, deobfuscation)
- support custom input formats (like xapk, split apk, etc)
- customize jadx-gui with additional features
Complete code for simple plugin can be found here: https://github.com/jadx-decompiler/jadx-example-plugin
To be able to use jadx API you need to add jadx-core dependency:
compileOnly("io.github.skylot:jadx-core:1.5.3")It is suggested to add it as a compile dependency to reduce plugin size,
because at runtime jadx-core will be used from jadx classpath
Plugin main class should implement jadx.api.plugins.JadxPlugin interface and fill some information about plugin:
import jadx.api.plugins.JadxPlugin;
import jadx.api.plugins.JadxPluginContext;
import jadx.api.plugins.JadxPluginInfo;
public class JadxExamplePlugin implements JadxPlugin {
public static final String PLUGIN_ID = "example-plugin";
@Override
public JadxPluginInfo getPluginInfo() {
return JadxPluginInfoBuilder.pluginId(PLUGIN_ID)
.name("Jadx example plugin")
.description("Add jadx watermark comment to every class")
.homepage("https://github.com/jadx-decompiler/jadx-example-plugin")
.requiredJadxVersion("1.5.3, r2504")
.build();
}
@Override
public void init(JadxPluginContext context) {
// plugin init code
}
}Next, to be able to auto discover plugin, you need to add resources/META-INF/services/jadx.api.plugins.JadxPlugin file
with full name of your plugin class
To prevent runtime exceptions because of using Jadx APIs added in new versions, it is suggested to set a requiredJadxVersion property in plugin info.
Format of version string: <target jadx release version>, r<revision number>
-
<target jadx release version>- 3 number version like1.5.2 -
<revision number>- revision number for jadx unstable builds (see below how to set it)
If plugin compiled with stable jadx-core library, use follow string according to jadx library version:
jadx-core version |
requiredJadxVersion string |
|---|---|
| 1.5.3 | "1.5.3, r2504" |
| 1.5.2 | "1.5.2, r2472" |
| 1.5.1 | "1.5.1, r2333" |
If plugin compiled with snapshot (unstable) version, set release version to snapshot version + 0.0.1 and revision number to latest unstable build version from here or get it from git: git rev-list --count HEAD.
For example, for jadx-core library with version 1.5.2-SNAPSHOT use "1.5.3, r2475"
Note
It is possible to release plugin for unstable version and during plugin install jadx will search compatible plugin version in latest plugin releases (now limited to 10 latest releases)
Root of public plugins API is a JadxPluginContext
interface which available in plugin init method.
Useful method:
-
addPass- jadx pass is a common way to insert custom logic into decompilation pipeline -
registerOptions- allows plugin to add custom options, such options will be available from jadx-cli and jadx-gui -
getGuiContext- if plugin used inside jadx-gui this method will return JadxGuiContext to customize UI.
Warning
Make sure to check if getGuiContext returns not null before use, because it will be null in jadx-cli and in jadx-gui to collect plugin options for preferences
After packing the plugin into jar, you can install it in jadx like this:
- for jadx-cli:
jadx plugins --install-jar jadx-example-plugin.jar - for jadx-gui: in menu
Pluginsgo toInstall pluginand select you plugin jar
If you want to make your plugin easy to discover, you can add it to 'jadx plugins community list': https://github.com/jadx-decompiler/jadx-plugins-list
Plugins from this list are shown in:
- jadx-cli:
jadx plugins --available - jadx-gui: open
Preferencesgo toPluginssection, check plugins inAvailablelist
Note
Now plugins can be published only using GitHub release artifacts (see 'Github release' section below), check a full list of supported methods here.
To use Github releases and install plugin by locationId:
- jadx-cli:
jadx plugins --install "github:<owner>:<plugin repo>" - jadx-gui: open
Preferencesgo toPluginssection ->Install pluginbutton
Prepare Github release with plugin artifact using name in format <repo name>-<version>.jar.
Here <version> will be used as a version of plugin and shown in UI, version format is not verified, but common smantic versioning is preferred: <major>.<minor>.<patch>.
Full example: jadx-example-plugin-0.1.1.jar
Before sharing result locationId make sure to check if jadx can correctly install plugin using methods mentioned above.