A while ago I wrote about Roboguice. I used 1.1 way back then. Now I switched to version 2.0 beta 2.

The changes

First of all we need a few new jars.

I found out the hard way that I needed 4.

You can find the latest beta on maven.

You can find the Guice 3.0 noaop jar on

The javax.inject.jar can also be found on

And the android v4 support jar I found on java2s.

Then secondly, you no longer need to have a class inheriting from RoboApplication, which also means that you can remove the name (application tag) in AndroidManifest.xml. And your modules class no longer needs to inherit RoboModule anymore. It now inherits from AbstractModule.

And if you really need that module you can make a roboguice.xml file in the res/values folder.

After that everything went just fine, not really. But I got it to work in the end.

The application

You can find my test application on github. It’s a notes Application and looks something like this.

It uses 3 different Activities, an SQLite database and RoboGuice of course. It has no tests yet and I wouldn’t call it MVC either. I made it for android 2.2.

It uses @Inject and @InjectView.


The lack of documentation was killing my productivity for a bit, but I got there in the end. And I now understand how it works, more or less. Something to note when you come from .Net IoC containers is that Guice seems to prefer using property injection over constructor injection and that it lets you inject implementation instead of interfaces.