无法实例化应用程序匕首 android

Unable to instantiate application dagger android

我正在将 Dagger 集成到我的应用程序中 当我 运行 应用

时遇到这个问题
java.lang.RuntimeException: Unable to instantiate application com.mine.parsexml.ParseApplication: java.lang.ClassNotFoundException: Didn't find class "com.mine.parsexml.ParseApplication" on path: DexPathList[[zip file "/data/app/com.mine.parsexml-4NxKMOI9esXH_ar6UHYk5w==/base.apk"],nativeLibraryDirectories=[/data/app/com.mine.parsexml-4NxKMOI9esXH_ar6UHYk5w==/lib/x86, /system/lib, /system/product/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
    at android.app.ActivityThread.access00(ActivityThread.java:219)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)

这是应用程序class - 也已在清单中声明

@HiltAndroidApp
class ParseApplication: Application()

应用级别gradle

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'

} 应用插件:'kotlin-android'

android {
compileSdk 31

defaultConfig {
    applicationId "com.mine.parsexml"
    minSdk 23
    targetSdk 31
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
    viewBinding true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
kotlinOptions {
    jvmTarget = '1.8'
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/AL2.0'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/gradle/incremental.annotation.processors'
    exclude("META-INF/*.kotlin_module")
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "com.google.android.exoplayer:exoplayer:2.16.0"
implementation "com.google.dagger:hilt-android:2.39.1"
implementation "com.google.dagger:hilt-android-compiler:2.39.1"
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

}
repositories {
mavenCentral()
}

我的问题是 dagger 依赖的关键字错误 因为编译器必须使用 kapt 而不是实现

已更改

implementation "com.google.dagger:hilt-android-compiler:2.39.1"

kapt "com.google.dagger:hilt-android-compiler:2.39.1"