注意AS版本:
2.33版
3.0版
- 在整个项目的
build.gradle
中加入:dependencies { // other classpath definitions here classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' }
- 在
app/build.gradle
中分别加入:// 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.2' compile 'com.google.dagger:dagger:2.2' provided 'javax.annotation:jsr250-api:1.0' }
在app/build.gradle中 dependencies{//Dagger2 annotationProcessor 'com.google.dagger:dagger-compiler:2.4' compile 'com.google.dagger:dagger:2.4' provided 'javax.annotation:jsr250-api:1.0'}