0

Anyone can help me please, iam still learning android and DI in android with dagger and just try implement the simple concept with dagger but i found the error Execution failed for task ':app:kaptDebugKotlin' and there is the complete error log.


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)

complete error in gist https://gist.github.com/masdikaid/7ff6d03338aa2c16d37703fa4d0b8b98

And i just implement simple concept car and engine with component like this :

Car.kt this class just depend on engine class and only have run method.

class Car @Inject constructor(private val engine: Engine) {
    private val TAG: String = "Car"

    fun run() {
        engine.start()
        Log.i(TAG, "Car Run ...")
    }
}

Engine.kt engine class just the simple class that have start method.

class Engine @Inject constructor() {
    private val TAG = "Engine"
    fun start() {
        Log.i(TAG, "Engine Start")
    }
}

CarComponent.kt car componet just simple component with getCar method.


@Component(modules = [AndroidSupportInjectionModule::class])
interface CarComponent {
    fun getCar(): Car
}

myGradle

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'
}

and when i rebuild the project i stuck with Execution failed for task ':app:kaptDebugKotlin' error.

i had try replace kapt com.google.dagger:dagger-android-processor:2.17 and com.google.dagger:dagger-compiler:2.27 with annotationProcessor and error is gone but DaggerAppComponent not generated, what should i do for fix this.

Thanks for advance,

blanksix
  • 340
  • 1
  • 16

1 Answers1

0

finally i found that question in stack overflow and work for me, thanks

Cannot find DaggerAppComponent inside Application class

blanksix
  • 340
  • 1
  • 16