Error: "The value for annotation attribute InjectView.value must be a constant expression" on injection.

1,216 views
Skip to first unread message

Bevor

unread,
May 20, 2013, 11:41:40 AM5/20/13
to robo...@googlegroups.com
I just started with RoboGuice 2.0 but can't use injection because I always get this error in Eclipse:

 "The value for annotation attribute InjectView.value must be a constant expression".

Here are two examples:

    @InjectView(R.id.startView)
    private ImageView startView;
   
    @InjectFragment("taskFragment")
    private TaskFragment taskFragment;

Obviously there was an issue in 2011 (http://code.google.com/p/roboguice/issues/detail?id=139) which should have been fixed?
This happens within my library project, but all components like Activities or resource references (R.id.startView) are within this library (so RoboGuice doesn't know that it's a library). Any ideas how to get rid of this error? Or is this just an Eclipse validation issue? Maven clean, Project Update, Project clean doesn't help.

Mike Burton

unread,
May 21, 2013, 1:05:16 PM5/21/13
to robo...@googlegroups.com
Hi Bevor,

Yes, one of the problems with library projects is that their constants are no longer constant :)

As the bug report mentions, you can now use tags to work around this limitation.
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roboguice+...@googlegroups.com.
To post to this group, send email to robo...@googlegroups.com.
Visit this group at http://groups.google.com/group/roboguice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted

Mike Burton

unread,
May 21, 2013, 6:24:48 PM5/21/13
to robo...@googlegroups.com
It was fixed by adding tag support.  There is no direct fix for using a non-constant expression in an annotation.


On May 21, 2013, at 11:35 AM, Bevor <markus...@gmail.com> wrote:


Ok, but why is this marked as fixed then? Nevertheless, I think I will omit the field injection for now.
Reply all
Reply to author
Forward
0 new messages