Using Guice in your Android project

Some time ago I wrote the Pay It Square ( Android application for a couple friends as a way to promote their service on the Android platform.  Prior to this while I had done Java programming in the past it was not of the “advanced” variety, at least not as high level as what I do in .NET.  This being the case it was my first true exposure to DI in Java.

For DI on Android we used RoboGuice ( which allows for various forms of injection to assist the Android developer in developing the common boilerplate code (ie: getting a reference to a view in a related layout).

For my upcoming talk on Push Notifications talk I wanted to create the Android demonstration app using this tool.  Having been a while since my last big foray into Android I noticed that RoboGuice had recently been updated to version 2.0.  No problem, the instructions ( seemed clear enough.  However, I quickly found out that something was wrong.

After adding the files as Jar references and then as Library references I kept getting an error relating to the Provider and Class Not Found.  At first I thought I was not referencing the Jar files correctly in IntelliJ.  However, this was not the case.

After breaking things down to their simplest form, I found that a certain Jar file that I thought I had (courtesy of the RoboGuice download) was in fact not correct.  The answer to solving this was to download the files separately:

The problem child here is the javax inject library which supplies the ability for guice to “inject”.  The link above references a ZIP file which contains the javax.inject.jar file.  Add all three of these JAR files as Library references within IntelliJ and everything should work fine.  Leave comments if they dont.


One thought on “Using Guice in your Android project

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s