匕首2错误执行失败了任务':app:kaptdebugkotlin'
任何人都可以帮助我,IAM仍在使用匕首学习Android和DI,然后尝试用匕首实现简单的概念,但我发现任务失败了执行失败':app:kaptdebugkotlin',有完整的错误日志。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
> java.lang.reflect.InvocationTargetException (no error message)
GIST中的完全错误 https://gist.github.com/masdikaid/7ff6d03338aa2c16d377703fa4db8b98
具有这样的组件:
,我刚刚实现了简单的概念车和引擎, 此类仅取决于引擎类,只有运行方法。
class Car @Inject constructor(private val engine: Engine) {
private val TAG: String = "Car"
fun run() {
engine.start()
Log.i(TAG, "Car Run ...")
}
}
Engine.kt 引擎类只是具有启动方法的简单类。
class Engine @Inject constructor() {
private val TAG = "Engine"
fun start() {
Log.i(TAG, "Engine Start")
}
}
carcomponent.kt CAR组件仅使用GetCar方法简单组件。
@Component(modules = [AndroidSupportInjectionModule::class])
interface CarComponent {
fun getCar(): Car
}
我的 gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
id 'kotlin-kapt'
id 'kotlin-android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.mdidproject.movupapp"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// firebase
implementation 'com.google.firebase:firebase-auth-ktx:21.0.6'
implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
// dagger
implementation "com.google.dagger:dagger-android:2.35.1"
implementation "com.google.dagger:dagger-android-support:2.17"
kapt "com.google.dagger:dagger-android-processor:2.17"
kapt "com.google.dagger:dagger-compiler:2.27"
// testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
,当我重建项目时,我坚持执行任务失败':app:kaptdebugkotlin'错误。
我尝试过替换kapt com.google.google.google.dagger:匕首android处理器:2.17
和 com.google.dagger.dagger.dagger.dagger:dagger-compiler:2.27
带有AnnotationProcessor,错误已消失但是DaggerAppComponent并未生成,我该怎么办来解决此问题。
感谢您的进步,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我在堆栈溢出和为我工作中发现了这个问题,谢谢
finally i found that question in stack overflow and work for me, thanks
Cannot find DaggerAppComponent inside Application class