3

Roboguice is such a neat little tool to tidy up boilerplate Android view code.

I loved using the @InjectView annotation so that I didn't have to initialize each and every view field in the onCreate() method of my Activities like this:

@InjectView(R.id.title) TextView title;

As part of Google's sweeping changes to library projects for ADT 14+ (which on the whole are a welcome improvement), id fields in generated R classes are no longer final.

So now when you want to use Roboguice inside of library projects, the @InjectView annotations no longer compile because annotations are processed at compile time, and R.id.title is no longer final.

Bummer...

Anybody else out there using Roboguice and have a creative workaround?

Volo
  • 28,673
  • 12
  • 97
  • 125
Jonathan Schneider
  • 26,852
  • 13
  • 75
  • 99

3 Answers3

2

Android Annotations supports a resource name based injection with a compile-time check.

https://github.com/excilys/androidannotations/wiki/Library-projects

andrej_k
  • 481
  • 4
  • 7
2

I guess you best bet is to follow this bug report on roboguice to see what kind of solution they come up with: http://code.google.com/p/roboguice/issues/detail?id=139&sort=-id

Markus
  • 1,293
  • 9
  • 10
1

RoboGuice's recommendation is to replace the ID references by TAG ones instead: http://code.google.com/p/roboguice/wiki/LibraryProjects

Roberto Andrade
  • 1,793
  • 1
  • 21
  • 27