Roboguice recently launched the 2.0 version. Compared with 1.1, it has:
Improve the stability
Support Fragment
More concise and easy to use
However, because RoboGuice2 is not fully backward compatible with RoboGuice1.1, the project that originally developed using RobuGuice1.1 needs to make some modifications to the code to use RoboGuice2.0.
Here are some of the upgrade considerations for upgrading to RoboGuice2.0 using the Eclipse IDE development environment:
1. Download the new Roboguice Library, the Roboguice2.0 library consists of four libraries, as shown in the following illustration:
Libraries can be downloaded from the http://code.google.com/p/roboguice/.
2. The roboapplication in the original 1.1 did not exist in 2.0. 2.0 more convenient to use, the usual application if there is not a custom binding, you do not need to derive application.
3. If you use a custom module to define bindings, in 2.0 you can define it through XML, such as the res/values/roboguice.xml definition
<?xml version= "1.0″encoding=" utf-8″?>
<resources>
<string-array name= "Roboguice_modules" >
<item>com.pstreets.guice.demo.greetingmodule</item >
</string-array> </resources>
4. Classes originally derived from abstractandroidmodule were changed to Abstractmodule in 2.0, such as:
Ublic class Greetingmodule extends Abstractmodule {
@Override protected void Configure () {bind (Igreetingservice.class). to (Helloworld.class);//bind ( Igreetingservice.class). to (Hellochina.class); }
}
5. Modify the Androidmanifest.xml, remove the original defined Roboapplication derived class definition, and remove the Roboapplication derived class definition from the code.
These are the main steps to upgrade from RoboGuice1.1 to 2.0. Before learning 2.0, you can refer to the 1.1 introduction, the basic concept is still the same.