注意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'
}
Dagger2 注入框架配置
本文介绍如何在不同版本的Android Studio中配置Dagger2依赖项和插件,包括适用于2.33版和3.0版的具体步骤。通过在build.gradle文件中添加必要的依赖项和插件应用,实现代码注入。
1766

被折叠的 条评论
为什么被折叠?



