【发布时间】:2018-06-04 17:44:32
【问题描述】:
我正在为我的 android 应用程序使用 dagger 2 库,但它不会生成 Daggercomponent 类,所以我读到我应该启用注释处理器,但我在 android studio 3.1.2 的任何地方都找不到它,它不在设置中还将此代码添加到 gradle 并没有帮助
javaCompileOptions{
annotationProcessorOptions {
includeCompileClasspath true
}
}
请注意我说的是 3.1.2 版本。在以前的版本中,注释处理器在菜单中,但我在这个版本中找不到它
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.moein.volley_download_kotlin"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions{
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
implementation 'com.tonyodev.fetch2downloaders:fetch2downloaders:2.0.0-RC21'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.dagger:dagger:2.13'
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'
}
(我在github上的匕首实现代码不想在这里重写:https://github.com/codepath/android_guides/issues/331)
【问题讨论】:
-
你能发布你的 build.gradle 文件吗?一级应用
-
@LeviAlbuquerque 完成
-
查看答案@Moeinh77
-
@Moeinh77 运气好吗?
-
@LeviAlbuquerque 嘿 tnx 询问但不幸的是还没有。我的gradle构建时间也突然变得非常非常慢
标签: android dependency-injection annotations dagger-2