由于Gradle7的语法变动,这里以引用aspectjx为例:
- 在最外层的build.gradle里增加classpath的引用
buildscript {
dependencies {
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
}
}

- 修改settings.gradle里的配置
增加阿里云的jcenter镜像(因为aspectjx存于jcenter中)
maven { url 'https://maven.aliyun.com/repository/public' }
修改repositoriesMode的参数,改为RepositoriesMode.PREFER_SETTINGS(原本的参数为RepositoriesMode.FAIL_ON_PROJECT_REPOS)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}

- 在app目录下的build.gradle里增加插件引用
apply plugin: 'android-aspectjx'

- 最后编译即可
网友评论