You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-guice
I'm injection a constant String into a provider to configure some
info, but I don't want the constant to be required. Thus I'd like to
make it @Nullable so that I can use a sensible default if one isn't
provided.
public class SharedPreferencesProvider implements
Provider<SharedPreferences> {
protected static final String DEFAULT = "default";
Seems pretty straightforward, but I keep running into the following
exception:
E/AndroidRuntime( 803): com.google.inject.CreationException: Guice
creation errors:
E/AndroidRuntime( 803):
E/AndroidRuntime( 803): 1) No implementation for java.lang.String
annotated with @com.google.inject.name.Named
(value=sharedPreferencesContext) was bound.
E/AndroidRuntime( 803): while locating java.lang.String annotated
with @com.google.inject.name.Named(value=sharedPreferencesContext)
E/AndroidRuntime( 803): for field at
roboguice.inject.SharedPreferencesProvider.context(Unknown Source)
E/AndroidRuntime( 803): at roboguice.config.AndroidModule.configure
(AndroidModule.java:52)
E/AndroidRuntime( 803):
E/AndroidRuntime( 803): 1 error
E/AndroidRuntime( 803): at
com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist
(Errors.java:354)
E/AndroidRuntime( 803): at
com.google.inject.InjectorBuilder.initializeStatically
(InjectorBuilder.java:152)
E/AndroidRuntime( 803): at com.google.inject.InjectorBuilder.build
(InjectorBuilder.java:105)
E/AndroidRuntime( 803): at com.google.inject.Guice.createInjector
(Guice.java:92)
...
Am I missing something?
Cheers,
Mike
limpb...@gmail.com
unread,
Nov 21, 2009, 2:18:17 AM11/21/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-guice
I think you've mixed up nullable with optional. You probably want
this:
@Inject(optional=true) @Named("sharedPreferencesContext") protected
String context;