Dagger2不生成Daggercomponent类 [英] Dagger2 not generating Daggercomponent classes
问题描述
Dagger2不会在android studio中生成任何组件类,我知道它是一个已知的问题,尽管我已经通过几乎所有方法在android studio中实现并尝试了各种教程,但是每次碰到这里,它都无法建立daggercomponent类。我也尝试过重建,清理渐变并使缓存无效,但这无济于事。
这是我的示例项目build.gradle
Dagger2 is not generating any component classes in android studio i know its a known problem while i have gone through almost all ways to implement in my android studio and have tried on various tutorials but every time i got struck here, it fails to build the daggercomponent class . I have also tried to rebuild ,clean gradles and invalidate caches but it does not help . Here is my one of sample project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.g.daggerillkillu"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
maven{url "https://jetpack.io"}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
provided 'javax.annotation:jsr250-api:1.0'
}
vehiclemodule.java
vehiclemodule.java
@Module
public class vehiclemodule {
@Provides
@Singleton
Motor providesMotor(){
return new Motor();
}
@Provides
@Singleton
Vehicle provideVehicle(){
return new Vehicle(new Motor());
}
}
vehicleComponent.java
vehicleComponent.java
@Singleton
@Component(modules = {vehiclemodule.class})
public interface VehicleComponent {
Vehicle provideVehicle();
}
android studio有问题吗?还是我做错了事? / p>
Is there any problem in the android studio or i am doing something wrong?
推荐答案
android studio有问题吗?还是我做错了事?
Is there any problem in the android studio or i am doing something wrong?
如果未生成任何内容,则很可能未启用注释处理:
If nothing is being generated then you most likely do not have annotation processing enabled:
这篇关于Dagger2不生成Daggercomponent类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!