Last active
November 9, 2016 15:07
-
-
Save murano500k/cb8a8584c3277a058a8d02381f69c729 to your computer and use it in GitHub Desktop.
Dagger setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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