Building Project Gradle

Kay-Uwe Janssen edited this page Mar 21, 2017 · 30 revisions

Starting with version 2.3.0 the Android Plugin has built-in support for annotation processors. If you require to use an older version of the plugin you can find an older version of this page explaining the use of android-apt plugin here.

Here is a working sample for Android Plugin 2.3.0:

buildscript {
    repositories {
    dependencies {
        // replace with the current version of the Android plugin
        classpath ''

repositories {

apply plugin: ''

def AAVersion = 'XXX'
dependencies {
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25

        // If you have different applicationIds for buildTypes or productFlavors uncomment this block.
        //javaCompileOptions {
        //    annotationProcessorOptions {
        //        arguments = ["resourcePackageName": android.defaultConfig.applicationId]
        //    }

Adding more AA plugins

If you are using more AA plugins, you must declare additional dependencies:

dependencies {
    annotationProcessor "org.androidannotations:{plugin-name}:$AAVersion"
    compile "org.androidannotations:{plugin-name}-api:$AAVersion"

Substitute {plugin-name} with the real name of the plugin what you want to add.



If you want to use snapshot versions of AndroidAnnotations, you should configure your project with the snapshot repository.

Add this to your build.gradle file to access snapshots repo:

repositories {
    maven {
        url = ''

Then, under def AAVersion = 'XXX', add snapshot version this way:

def AAVersion = 'XXX'
def AASnapshotVersion = 'XXX-SNAPSHOT'

with XXX being the snapshot version. For 4.0 snapshot version, it would be:

def AASnapshotVersion = '4.0-SNAPSHOT'

Finally, in dependencies, where you use $AAVersion, use $AASnapshotVersion instead:

dependencies {
    annotationProcessor "org.androidannotations:androidannotations:$AASnapshotVersion"
    compile "org.androidannotations:androidannotations-api:$AASnapshotVersion"


Unlike release builds, where changing the version number to the next will make gradle fetch the new version on while building or assembling, snapshots keep the same version number, and are consequently not updated by gradle.

Thankfully, there's a way to force gradle to update snapshots, but it may take some time, or a while, depending of your connection and the size of the downloaded dependencies. Therefore, you shouldn't run the command below if the current snapshot is already up to date (you can check the recent commits on this repo), or if there's minor changes which don't impact you.

To perform the update, open a terminal in your root project's dir and add the --refresh-dependencies flag to any build gradle command.


As you are using a snapshot version, you are probably building a debug apk, so you can type:

./gradlew assembleDebug --refresh-dependencies

to assemble all your modules and update your project's dependencies, which should include AA's snapshot.

Next step

2/11/2017 The 4.4.0 release is out !

Using AndroidAnnotations


Enjoying AndroidAnnotations

Improving AndroidAnnotations

Extending AndroidAnnotations

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.