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