This is what works for me:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
configurations {
apt
}
repositories {
mavenRepo url: 'https://oss.sonatype.org/content/repositories/snapshots/'
}
ext.androidAnnotationsVersion = '3.0-SNAPSHOT';
dependencies {
compile 'com.android.support:support-v4:18.0.+'
apt "org.androidannotations:androidannotations:$ext.androidAnnotationsVersion"
compile "org.androidannotations:androidannotations-api:$ext.androidAnnotationsVersion"
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
}
android.applicationVariants.all { variant ->
ext.aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
ext.aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.asPath,
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', ext.aptOutput
]
}
After that I need to mark build/sources/apt-generated/debug
as source in Android Studio by right clicking it and selecting Mark Directory as
> Source Root