I tried to install android annotations in android studio 0.4.2 with gradle but it can't configure the MainActivity_ class
I configured Compiler-> Annotations proccesors Here's a picture !
and this is a part of my build.gradle
configurations {
apt
}
dependencies {
compile 'com.android.support:gridlayout-v7:19.0.1'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
//android annotations
compile 'org.androidannotations:androidannotations-api:3.0'
apt 'org.androidannotations:androidannotations:3.0'
}
def getSourceSetName(variant) {
return new File(variant.dirName).getName();
}
android.applicationVariants.all { variant ->
aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}
}
I can inject views in my activity but it doen't find the MainActivity_ class
In the countless tutorials that i've read says that i need to mark the generated directory as Source , but i can't do that with android studio 0.4.2
Any help, appreciated!
A working solution has been submitted on the github issue: source folders have to be configured via gradle. So the configuration for android part should look like this :
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'YOUR_OTHER_PRODUCTION_SOURCE_FOLDER']
resources.srcDirs = ['src/main/res']
res.srcDirs = ['src/main/res']
}
}
}
Also, I agree with Eugen, you really should use the new android-apt plugin. This has been explained on the wiki page of AA project. I'm gonna add a part of how to configure AA on Android studio to clarify this point.