请帮我将Dagger 2连接到Kotlin。 我的应用程序的构建 gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "mobile.socialboards.com"
minSdkVersion 21
targetSdkVersion 28
versionCode 19
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains' , module:'annotations'
}
productFlavors {}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs = ['-Xjvm-default=enable']
}
lintOptions {
abortOnError false
}
}
kapt {
generateStubs = true
}
dependencies {
...
implementation 'com.google.dagger:dagger-android:2.14.1'
implementation 'com.google.dagger:dagger-android-support:2.14.1' // if you use the support libraries
implementation "com.google.dagger:dagger:2.14.1"
kapt 'com.google.dagger:dagger-android-processor:2.12'
kapt "com.google.dagger:dagger-compiler:2.14.1"
compileOnly "org.glassfish:javax.annotation:3.1.1"
}
apply plugin: 'com.google.gms.google-services'
我正在进行同步和重建,但是在我的应用程序 kotlin 类中,Android Studio 找不到 DaggerAppComponent。我查阅了很多文章,但仍然不理解出了什么问题。请帮忙!
com.google.dagger:dagger-android
作为依赖项。你需要创建自己的AppComponent类。DaggerAppComponent类将会为你生成。 - chrjsjavac
的输出中显示;而logcat
通常是指正在运行的Android设备上的设备日志。 - Jeff Bowman