3

随着'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。有没有什么办法解决这一问题?Gradle 2.0.0-beta4使得AndroidAnnotation不起作用

回答

3

您必须为此使用AA 4.0-SNAPSHOT。为AA快照

添加存储库:

repositories { 
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } 
} 

更改AA版本至4.0快照

dependencies { 
    compile "org.androidannotations:androidannotations-api:4.0-SNAPSHOT" 
    apt "org.androidannotations:androidannotations:4.0-SNAPSHOT" 
} 

添加library:trueapt说法:

apt { 
    arguments { 
     androidManifestFile variant.outputs[0].processResources.manifestFile 
     resourcePackageName android.defaultConfig.applicationId 

     //only for Android Annotations 4.0-SNAPSHOT 
     library 'true' 
    } 
} 

这样AA不验证EApplication,的存在等在您的清单,因此它将与即时运行编译。原因是即时运行会在清单中更改您的应用程序类,这就是AA无法在其中找到生成的应用程序类的原因。

更新: AA 4.0快照是模块化的,这意味着你必须添加AA REST客户端模块,以及在你的build.gradle

org.androidannotations:rest-spring:4.0-SNAPSHOT 
org.androidannotations:rest-spring-api:4.0-SNAPSHOT 

而且你必须改变REST注释进口org.androidannotations.rest.spring.annotations.*

+0

嗨。感谢您的答复。作为你的回答,这里是我得到的错误: '错误:(3,47)错误:包org.androidannotations.annotations.rest不存在 错误:(4,47)错误:package org.androidannotations.annotations。休息不存在 错误:(5,39)错误:程序包org.androidannotations.api.rest不存在 错误:(13,33)错误:找不到符号类RestClientErrorHandling 错误:(12,2)错误:找不到符号类休息 错误:(34,6)错误:无法找到符号类获取' – maohieng

+0

我更新了答案。 – WonderCsabo