I am using RoboGuice 3.0 in Android Studio directly since I need support for ActionBarActivity. This is my dep:
compile 'org.roboguice:roboguice:3.0'
First odd thing I had to do was to resolve a ClassNotFoundException for "Unable to use annotation database(s)". It seems like if there's no annotation package given, the packageList is prepended with empty string and DI framework complains that it could not find AnnotationDatabaseImpl at root package (which is expected). So I did this in my manifest:
<meta-data android:name="roboguice.annotations.packages" android:value="roboguice"/>
which resolved the issue. Then, I changed my code to this:
@ContentView(R.layout.activity_playlists)
public class Playlists extends RoboActionBarActivity {
@InjectView(R.id.toolbar)
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setSupportActionBar(toolbar);
}
}
setSupportActionBar() throws a NPE. I stepped through the debugger and viewMembersInjectors map is empty when the views are being injected. I am thinking the odd fix I had to do and this is related. Somehow the injectview member is not discovered. However my @ContentView injection works (if I remove it content changed callback is never called).
Does anyone know how to fix this?