使用 'com.android.tools.build:gradle:1.5.0'
和 'com.neenbedankt.gradle.plugins:android-apt:1.8'
, AndroidAnnotation 可以很好地处理注释。但是在我更新到 'com.android.tools.build:gradle:2.0.0-beta4'
即时运行后,AndroidAnnotation 似乎无法生成 @EApplication。有什么办法可以解决这个问题吗?
最佳答案
为此你必须使用 AA 4.0-SNAPSHOT。
为 AA 快照添加存储库:
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
将 AA 版本更改为 4.0-SNAPSHOT
dependencies {
compile "org.androidannotations:androidannotations-api:4.0-SNAPSHOT"
apt "org.androidannotations:androidannotations:4.0-SNAPSHOT"
}
将 library:true
添加到 apt
参数:
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName android.defaultConfig.applicationId
//only for Android Annotations 4.0-SNAPSHOT
library 'true'
}
}
这样 AA 不会验证 list 中是否存在 EApplication
、EActivity
等,因此它将使用 Instant Run 进行编译。原因是 Instant Run 更改了 list 中的应用程序类,这就是为什么 AA 无法在其中找到生成的应用程序。
更新:AA 4.0-SNAPSHOT 是模块化的,这意味着您还必须在 build.gradle 中添加 AA REST 客户端模块
org.androidannotations:rest-spring:4.0-SNAPSHOT
org.androidannotations:rest-spring-api:4.0-SNAPSHOT
并且您必须将 REST 注释导入更改为 org.androidannotations.rest.spring.annotations.*
。
关于android-studio - Gradle 2.0.0-beta4 使 AndroidAnnotation 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35423845/