Skip to content

Eclipse Project Configuration

pyricau edited this page Apr 12, 2012 · 14 revisions

Once you have downloaded AndroidAnnotations, you may add it to your projects.

Warning: Make sure executing java -version in a prompt shows version 1.6.X.

Warning: Annotation processing is not well implemented on Eclipse 3.4.X. Please use at least Eclipse 3.5.

Note: If you use Maven in your Android projects, please follow the Maven + Eclipse instructions instead.

Configuring Eclipse

Please note that there are two important JARs in AndroidAnnotations:

  • androidannotations-X.X.X-api.jar is the API JAR, it must be in your build path and will be part of the final APK
  • androidannotations-X.X.X.jar is the processor JAR, it's only needed at compile time, and must be in the compiler classpath.

Do the following to use AndroidAnnotations within the Eclipse IDE:

  1. Put androidannotations-X.X.X-api.jar in the libs folder
  2. Put androidannotations-X.X.X.jar in another folder, for instance ext-libs. androidannotations-X.X.X.jar must not go in the libs folder.
  3. Right-click your project, choose "Properties"
  4. Go to Java Compiler and make sure that Compiler compliance level is set to 1.6, otherwise the processor won't be activated
  5. Go to Java Compiler > Annotation Processing and choose Enable annotation processing
  6. Go to Java Compiler > Annotation Processing > Factory Path and add the processor JAR : androidannotations-X.X.X.jar.
  7. Confirm the workspace rebuild
  8. Go to Java Build Path > Libraries and add the API JAR : androidannotations-X.X.X-api.jar, unless it's already in the build path (ADT 17 automatically adds JARs that are in the libs folder).
  9. You can start using AndroidAnnotations and you should now see any annotation problems as regular error markers within the editor and in the Problem view.

Troubleshooting

  • If you get a java.lang.IllegalArgumentException: already added: Lcom/googlecode/androidannotations/annotations/AfterInject; when compiling, please check that you did not put the processor jar androidannotations-X.X.X.jar in the libs folder.

  • If you get a java.lang.NoClassDefFoundError at runtime, please verify in project properties > Java Build Path > Order and Export that androidannotations-xxx-api.jar is checked.


This documentation is highly inspired (not to say c&p) from the Hibernate Validation Annotation Processor Documentation. If you do not use Eclipse, you will find it quite helpful.

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Clone this wiki locally