3

With 'com.android.tools.build:gradle:1.5.0' and 'com.neenbedankt.gradle.plugins:android-apt:1.8', AndroidAnnotation works well with processing the annotation. But after I update to 'com.android.tools.build:gradle:2.0.0-beta4' for instant run, it seems AndroidAnnotation cannot generate @EApplication. Is there any way to fix this?

maohieng
  • 1,646
  • 1
  • 19
  • 26

1 Answers1

3

You have to use AA 4.0-SNAPSHOT for this.

Add repository for AA snapshots:

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

Change AA version to 4.0-SNAPSHOT

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

Add library:true to apt argument:

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

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

This way AA does not validate the presence of EApplication, EActivity etc. in your manifest, hence it will compile with Instant Run. The cause is that Instant Run changes your application class in the manifest, that is why AA cannot find the generated one in it.

Update: AA 4.0-SNAPSHOT is modularized, that means you have to add the AA REST client module as well in your build.gradle

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

And you have to change the REST annotation imports to org.androidannotations.rest.spring.annotations.*.

WonderCsabo
  • 11,947
  • 13
  • 63
  • 105
  • Hi. Thanks for your response. As your answer, here is the error I get: `Error:(3, 47) error: package org.androidannotations.annotations.rest does not exist Error:(4, 47) error: package org.androidannotations.annotations.rest does not exist Error:(5, 39) error: package org.androidannotations.api.rest does not exist Error:(13, 33) error: cannot find symbol class RestClientErrorHandling Error:(12, 2) error: cannot find symbol class Rest Error:(34, 6) error: cannot find symbol class Get` – maohieng Feb 16 '16 at 09:55