A gradle plugin that enables AOP in android.
Alternatives To Roboaspectj
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
21 days ago8
收集整理Android开发所需的Android SDK、开发中用到的工具、Android开发教程、Android设计规范,免费的设计素材等。
Detekt5,6642815 hours ago30August 30, 2021157apache-2.0Kotlin
Static code analysis for Kotlin
Gradle Retrolambda5,3886834 years ago40April 21, 201974apache-2.0Java
A gradle plugin for getting java lambda support in java 6, 7 and android
Packer Ng Plugin4,796321a year ago12March 03, 201721apache-2.0Java
下一代Android打包工具(对Gradle 7.x的支持,欢迎提PR)
Gradle Versions Plugin3,68911134 days ago20May 31, 201784apache-2.0Kotlin
Gradle plugin to discover dependency updates
2 years ago145apache-2.0Groovy
A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
8 days ago240apache-2.0Groovy
Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
Aboutlibraries3,31728 days ago103July 17, 20239apache-2.0Kotlin
AboutLibraries automatically collects all dependencies and licenses of any gradle project (Kotlin MultiPlatform), and provides easy to integrate UI components for Android and Compose-jb environments
Dokka3,0341213 hours ago21June 05, 2023448apache-2.0Kotlin
API documentation engine for Kotlin
Dexcount Gradle Plugin3,015
5 months ago46January 16, 20232apache-2.0Java
A Gradle plugin to report the number of method references in your APK on every build.
Alternatives To Roboaspectj
Select To Compare

Alternative Project Comparisons


RoboAspectJ is a Gradle plugin to introduce AspectJ (Aspect-Orient Programming) to Android project. It compiles aspects(if needed) and weave them all together in FULL-PROJECT scope. This means project (or subproject) sources, external libraries and local dependencies will all be dealt with by default.

Note: This plugin may change due to the modification of transform-api. So you may keep track of RoboAspectJ to make sure you're using the most recent version.

latest version: v0.9.1


Android Plugin (application) 2.1.0


Add plugin dependency in buildscript classpath:

buildscript {
    dependencies {
        classpath 'com.meituan.gradle:roboaspectj:0.9.+'

Apply plugin:

apply plugin: 'com.meituan.roboaspectj'


There are basically 2 ways to write your aspects and weave them into production code:

As Source

write aspects in @AspectJ syntax under your project's java source directory. e.g. {$projectDir}/src/main/java/

As Library

compile and bundle your aspects independently using ajc, then make it dependency in build script. For example:

compile 'com.example.myaspects:library:1.0'

This way may be a little bit complicated. But it's suitable for those who want to maintain their aspects as an independent project.

Variant-Specific Concern

While RoboAspectJ is registered globally, we still can do our crosscutting concern under specific variant. Actually, this is already done by Android plugin.

As Source

put variant-specific aspects under corresponding folder.

For example, I want to do some performance monitoring in myflavor, so I will write aspects under ${projectDir}/src/myflavor/java/.

As Library

add variant-specific aspects dependency to corresponding configuration scope.

myflavorCompile 'com.example.myaspects:library:1.0'


There is an extension aspectj for you to do some tweaking.


If you want to leave some artifact untouched from AspectJ, using:

aspectj {
	exclude group: '', module: 'support-v4'

Java runtime

When applying rxjava or retrolambda, you may need jrt.jar as classpath. Configure it by:

aspectj {
	javartNeeded true


For debug or performance use, you can disable weaving:

aspectj {
    enable false    //by default, it's true and you don't have to add this statement.

alternatively, set roboaspectj.enable property false when run gradle.

$ gradle clean assembleDebug -Droboaspectj.enable=false

Maybe you want it to be smarter to disable it when it's a debug flavor, then add this to your build script:

aspectj {
    disableWhenDebug true // default is false

or, specify roboaspectj.disableWhenDebug property.

$ gradle clean assembleDebug -Droboaspectj.disableWhenDebug=true

Though weaving is disabled, Aspects and AspectJ compile dependencies are all still there. It's only the weaving step doesn't happen.

Note: Corresponding property has precedence over config in build script in both of these 2 cases. For instance, weaving will not take effect when your roboaspectj.enable property is false, no matter what you config in build script.


Code is under the Apache Licence v2.


This plugin is currently a prototype, and it still has much to improve. Feel free to contact: [email protected]

Popular Plugin Projects
Popular Gradle Projects
Popular Libraries Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Gradle Plugin