AndroidStudio2027版,Gradle7.0+,Kotlin使用AndroidAnnotations4.9.0最新配置,需配合butterknife使用 - gradle配置:
随着Studio和Gradle版本更新,包括AndroidAnnotations自己的更新,配置AndroidAnnotations方法一直在变。
目前使用Studio2021版+Gradle7.0以上,AndroidAnnotations4.9.0使用原来的配置,在Kotlin开发环境下会出问题,需要配合butterknife才能正常使用。
最后有完整代码。
一:先说根build.gradle配置:butterknife依赖和AndroidAnnotations的maven仓库
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1' //butterknife用于生成R2,配合androidannotations classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" }
// 此配置在新版中可能会放到settings.gradle中
allprojects {
repositories {
mavenCentral() mavenLocal() jcenter() google()
//androidannotations仓库地址 maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots' } } }
二:app的build.gradle配置:
使用kotlin的kapt配置,用于引入androidannotations依赖,使用annotationProcessor会失败
apply plugi
原文链接: 拼多多帮助力入口