I am trying to make a Hello World with AndroidAnnotations and Gradle in IntelliJ IDEA. (I only have some experience with IntelliJ, all the other stuff is completely new to me.)
I have created a new Gradle: Android Module in IntelliJ IDEA and then edited build.gradle
per "Configure your gradle" in the AndroidAnnotations' official guide.
Unfortunatelly, I get this error saying I have no idea what (on line 18: apply plugin: 'android-apt'
)
Gradle: A problem occurred evaluating project ':Hello'.
> Could not find property 'androidTestCompile' on configuration container.
Here is my build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
repositories {
mavenCentral()
mavenLocal() // cache (USER_HOME/.m2 folder)
}
apply plugin: 'android'
apply plugin: 'android-apt' // This is the line of the error
def AAVersion = '3.0.1' // IS THIS OK?
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'com.hello.app'
// 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 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// 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']
}
}
}
androidTestCompile
was introduced in version 0.9.0 of the Android Gradle plugin (and I was using 0.7.+ here), so 0.9.0 is the minimum one should use with android-apt
's newer versions (3.0.1 here).
Also, you might have some more problems with incompatible versions of all these tools.
Here is a table of version compatibility among Android Studio, Android Gradle plugin and Gradle