Android AOP aspectj 配置

沪江插件gradle_plugin_android_aspectjx: https://github.com/HujiangTechnology/gradle_plugin_android_aspectjx

以点击防重为例

project module

1
2
3
4
5
6
7
8
9
10
11
12
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.0'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'
}
}

app module

参考:https://github.com/HujiangTechnology/gradle_plugin_android_aspectjx/issues/96

1
2
3
4
5
6
7
apply plugin: 'android-aspectjx'

aspectjx {
//include 'cn.appblog.common.utils.click.SingleClickAspect'
// fix Didn't find class "com.umeng.message.provider.MessageProvider" on path: DexPathList
exclude 'com.umeng.message'
}

需要点击防重的module

1
apply plugin: 'android-aspectjx'

common module (即声明SingleClickAspect的module)

1
2
3
dependencies {
api "org.aspectj:aspectjrt:1.9.4"
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :