我正在尝试使用Dagger 2进行依赖注入。目前我正在添加这样的依赖项。
在build.gradle中
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
在app / build.gradle中
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
testCompile 'junit:junit:
compile 'com.android.support:appcompat-v7:23.2.0'
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
}
问题是,我们正在创建一个SDK(模块),它将被其他应用程序包含在内,所以我不想在build.gradle中包含依赖项。因此,我必须告诉其他应用程序在其主build.gradle文件中包含Dagger2
依赖项。
另外,如果有任何方法可以使用jar包含匕首库,请告诉我。
提前致谢:)
答案 0 :(得分:2)
试试这个
将此添加到build.gradle
dependencies {
// other classpath definitions here
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
然后在你的app / build.gradle中:
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'
}
请注意,提供的关键字是指仅在编译时需要的依赖项。
希望这有帮助