Skip to content

Eclipse Project Configuration

pyricau edited this page Jun 14, 2012 · 14 revisions

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

Notes:

  • Make sure executing java -version in a prompt shows at least version 1.6.X.
  • Please use at least Eclipse 3.5. Annotation processing is not well implemented on Eclipse 3.4.X.
  • 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 is 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 on 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

Troubleshooting

  • When AndroidAnnotations is activated, You should now see any annotation problem as a regular error marker within the editor and in the Problem view.

  • Your project name should be identical to the name of the folder containing the project. When importing a project in Eclipse, the project name used is the name of the folder. Since the annotation jar is referenced by projectName/lib/androidannotations-X.X.X.jar, you may otherwise encounter errors when coworkers import your project.

  • 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