Skip to content

Installation

Donn Felker edited this page Oct 12, 2012 · 1 revision

Downloading and Installing

Installation

Download RoboGuice and guice-2.0-no_aop.jar (not guice-3.0).

Create a new Android Project (or use an existing one), targeting at least platform 1.5, API level 3 and SDK Version 3.

Add the two jars to the build path of your Android project

  • Eclipse : Project > Properties > Java Build Path > Libraries > Add External JARs
  • IntelliJ: File -> Project Structure -> Modules ->Your App -> Dependencies -> Add -> Single Entry Module...

Your First RoboGuice Application!

Create a new class that extends RoboApplication (let's call it MyApplication).

Update the android:name attribute of application in the AndroidManifest.xml to set your newly created application. For instance, in our example it would be :

<application android:name="com.mycompany.myproject.MyApplication" ... >

Create a configuration Module class that extends AbstractAndroidModule (let's call it MyModule). Implement the configure() method to add your own bindings. See the Google Guice Wiki to learn more about configuring Modules.

Override RoboApplication.addApplicationModules(List<Module>) method in your application class. Add a new instance of your custom Module to the list. For instance :

public class MyApplication extends RoboApplication { protected void addApplicationModules(List modules) { modules.add(new MyModule()); } }

Make your activities extend from RoboActivity instead of Activity.

You are ready to start using RoboGuice! To see examples of what you can do, check out the example in the samples directory.

Clone this wiki locally