Update: Intellij 12 + Android Annotations 2.7 + maven
This is my previous post updated for the new versions of intelliJ Idea 12 and Android Annotations 2.7
I couldn't get it to work with processor from classpath, so I use the path from maven repo. For intelliJ Idea 12 you have to add 3 jars like so (the path are from my own mvn repo):
I use <project path> + /target/generated-sources/r
Hope someone else finds this useful. Feel free to add or correct me.
1. Create your project with Android Maven Plugin
Read the GettingStarted
You can run this command to get the basic structure:
mvn archetype:generate \ -DarchetypeArtifactId=android-quickstart \ -DarchetypeGroupId=de.akquinet.android.archetypes \ -DarchetypeVersion=1.0.9 \ -DgroupId=com.tagonsoft \ -DartifactId=ExampleApp
Add/Edit the dependency to android:
With android from central mvn repository:Or with android from maven-android-sdk-deployer:com.google.android android 4.1.1.4
Run 'mvn idea:idea' to get the basic idea project to start with.android android 4.2_r1 provided
2. Add AndroidAnnotations to maven pom.xml
com.googlecode.androidannotations androidannotations 2.7.1 provided com.googlecode.androidannotations androidannotations-api 2.7.1
3. Configure Idea compiler
Like so:I couldn't get it to work with processor from classpath, so I use the path from maven repo. For intelliJ Idea 12 you have to add 3 jars like so (the path are from my own mvn repo):
/work/libs/mvnrepo/com/googlecode/androidannotations/androidannotations/2.7.1/androidannotations-2.7.1.jar:/work/libs/mvnrepo/com/googlecode/androidannotations/androidannotations-api/2.7.1/androidannotations-api-2.7.1.jar:/work/libs/mvnrepo/com/sun/codemodel/codemodel/2.4.1/codemodel-2.4.1.jar
The jars are androidannotations-2.7.1.jar, androidannotations-api-2.7.1.jar and codemodel-2.4.1.jar. The separator is ':'.
Add as processor FQ name:
com.googlecode.androidannotations.AndroidAnnotationProcessor
4. Tweak your module to regenerate R file in the new location:
I use <project path> + /target/generated-sources/r
Hope someone else finds this useful. Feel free to add or correct me.
Regarding: "The solution I found on the internet is to leave gen as sources and to exclude the folders beneath it." - how do you get the "gen" folder in the first place? It shouldn't exist if you created the project via mvn archetype. There should be no 'gen' folder nor will it be created. Only /target/generated-sources/
ReplyDeleteyou are right, my guess is that it happened before I unstructed Idea to generate R in the same location as maven. I remember I had this problem with idea 11, now it looks clean.
ReplyDeleteWith new version of Intellij IDEA we can add Maven as supported framework. I found this article describing pretty details how to configure AA with Maven in Intellij IDEA
ReplyDeletehttp://hintdesk.com/android-introduction-to-androidannotations-maven-in-intellij-idea/
Just another instructions.