Reputation: 3646
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!
Upvotes: 1
Views: 1251
Reputation: 1561
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.
Upvotes: 1
Reputation: 20140
First of all forget about changing settings for annotation processing inside Android Studio with gradle
project. Android Studio delegates all build processing to gradle
and just reflects state and errors.
Second, please remove your workarounds for having code generation done in gradle and start using Hugo Visser's android-apt
plugin: https://bitbucket.org/hvisser/android-apt
Please pay attention about how to correctly pass arguments for android-annaotaiton
processor through plugin settings.
Success!
Upvotes: 2