无法导入@Inject注释

use*_*174 5 java android kotlin dagger-hilt kmm

我已经在我的项目中实现了 Hilt 依赖项,但是当我的构造函数需要 @Inject 注释时,它不起作用。基本上,当我尝试手动导入它时,我发现 javax 内的注入文件夹是空的。所以结构就像javax.inject。之后我什么也没得到,因为注入文件夹是空的。我尝试过重建和清理他的项目。我也尝试过使缓存无效,但似乎没有任何效果。我怎样才能做到这一点?

依赖项列表

dependencies {
    implementation(project(":shared"))

    implementation(AndroidX.appCompat)

    implementation(Compose.runtime)
    implementation(Compose.runtimeLiveData)
    implementation(Compose.ui)
    implementation(Compose.material)
    implementation(Compose.uiTooling)
    implementation(Compose.foundation)
    implementation(Compose.compiler)
    implementation(Compose.constraintLayout)
    implementation(Compose.activity)
    implementation(Compose.navigation)

    implementation(Google.material)

    implementation(Hilt.hiltAndroid)
    implementation(Hilt.hiltNavigation)
    kapt(Hilt.hiltCompiler)

    implementation(Kotlinx.datetime)

    debugImplementation(SquareUp.leakCanary)
}
Run Code Online (Sandbox Code Playgroud)

刀柄版本 - 2.37

小智 0

我相信你缺少 gradle 文件中的插件

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}
Run Code Online (Sandbox Code Playgroud)