-
Notifications
You must be signed in to change notification settings - Fork 0
Building Project Gradle
Preferred way
You can use the android-apt Gradle plugin to launch AndroidAnnotation processing.
Here is a quick working sample:
buildscript {
repositories {
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:1.0.0'
// replace with the current version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = 'XXX'
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
resourcePackageName 'com.myproject.package'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
// This is only needed if you project structure doesn't fit the one found here
// http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure
sourceSets {
main {
// manifest.srcFile 'src/main/AndroidManifest.xml'
// java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}']
// resources.srcDirs = ['src/main/resources']
// res.srcDirs = ['src/main/res']
// assets.srcDirs = ['src/main/assets']
}
}
}Note: Don't forget to adjust android.sourceSets.main configuration to fit your needs if necessary. For example, in IntelliJ source files are in src/main folder while in Eclipse there are in src folder. You should also specify the folder where the generated classes will be written.
Deprecated
There is also a Gradle AndroidAnnotations Plugin to use AndroidAnnotations in Gradle project. This plugin generates output files based on annotations on compile; it also configures IDEA projects to use AndroidAnnotations.
Unfortunately this plugin seems to not be maintained anymore.
Instructions can be found in the plugin wiki.
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
09/11/2014 The 3.2 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow