Question

I use AndroidAnnotations, and since a couple of days, Eclipse sometimes (not always) fails to compile code that uses classes generated by AndroidAnnotations (pre-compile generated code):

My example is:

My project has MainActivity, AndroidAnnotations creates an extended class MainActivity_ under .apt_generated.

Elsewhere in the DetailActivity, my code has a reference to MainActivity_:

enter image description here

My solution so far was to remove the code, compile, then add the code back. However, this is far from elegant. It also is quite annoying and time-consuming.

Am I missing some setting?

Does the order in the "Order and Export" page have any influence? I've tried to move the .apt_generated directory up and down, with no positive effect.

I was thinking that this is the same concept used by Android's resource class R. I never had any issues with code that use resources failing to compile.

Était-ce utile?

La solution 2

Autres conseils

When does that happen?

  • When you open Eclipse?
  • When you open a project previously closed?
  • When you do a project > clean?

This problem looks like a bug in Eclipse. It looks like sometimes it compiles a class, then run the annotation processor, then doesn't update / recompile the classes that had missing symbols.

A simple tricks that seems to do the job: go to the properties of the project, change the name of the annotation processing folder from .apt_generated to something else (and then back to .apt_generated), and accept the rebuild. This seems to trigger a build in the right order, and reset everything right.

Note that AndroidAnnotations uses annotation processing, which is a standard java 6 concept. It's different from the Android R class, which isn't linked to any java standard.

Does that help?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top