I've just upgraded our project to use Roboguice 3 and all of a sudden all the injected objects became null, that includes POJO, Providers, Views, Resources etc. And I'm struggling to figure out why.
First of all there's the gradle build file, tried both Proguard on and off and it didn't make a difference. I believe we are currently using Roboguice 3.0.1, but I tried 3.0 and still had the problem.
compile ('org.roboguice:roboguice:3.+') {
exclude module: 'asm'
}
provided 'org.roboguice:roboblender:3.+
And we do have some custom bindings in a Module file, so here's how I'm specifying it according to the wiki:
<meta-data
android:name="roboguice.modules"
android:value="com.some.CustomModule"/>
Just for the record I've also tried to specify it in the Application class like this and it didn't work:
RoboGuice.getOrCreateBaseApplicationInjector(
this,
RoboGuice.DEFAULT_STAGE,
RoboGuice.newDefaultRoboModule(this),
new CustomModule(this));
That's about it for the setup, we didn't change anything and if I use Roboguice 2, everything works.
A couple other things that I've also tried:
- Also tried without Roboblender and annotation db
RoboGuice.setUseAnnotationDatabases(false);
it didn't make a difference. Ln.d("Test" + Strings.toString(0));
this logs prints out just fine so I think the actual library is packaged right.- Instead of injecting a Provider of a POJO, I tried to use manual injection like this
RoboGuice.getInjector(this).getInstance(SharedPreferencesHelper.class);
and it throws the error aboutCould not find a suitable constructor in some.path.SharedPreferencesHelper. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
The weird thing is that in SharedPreferencesHelper class we do have a public constructor with@Inject
annotated, I guess somehow it's not taken into consideration? Maybe this whole problem is due to annotation not being considered?
I've been banging my head against it for a couple days now and would really appreciate any input or more stuff to try.