Skip to content

Instantly share code, notes, and snippets.

@murano500k
Last active November 9, 2016 15:07
Show Gist options
  • Save murano500k/cb8a8584c3277a058a8d02381f69c729 to your computer and use it in GitHub Desktop.
Save murano500k/cb8a8584c3277a058a8d02381f69c729 to your computer and use it in GitHub Desktop.
Dagger setup
root level:
dependencies {
// other classpath definitions here
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
app level:
// add after applying plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
// apt command comes from the android-apt plugin
apt 'com.google.dagger:dagger-compiler:2.7'
compile 'com.google.dagger:dagger:2.7'
provided 'javax.annotation:jsr250-api:1.0'
}
sample:
public class MainActivity extends Activity {
@Inject MyTwitterApiClient mTwitterApiClient;
@Inject SharedPreferences sharedPreferences;
public void onCreate(Bundle savedInstance) {
// assign singleton instances to fields
InjectorClass.inject(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment