当我尝试在 Android Studio 中运行或构建应用程序时收到此警告。为什么我会得到这个?我需要注意这个警告吗?
The following options were not recognized by any processor: '[dagger.fastInit, kapt.kotlin.generated]'
将
id "kotlin-kapt"
移至 plugins{}
模块级别中 build.gradle
的底部。
对我来说,将其添加到构建文件(在 android 块中)修复了它:
hilt {
enableAggregatingTask = true
}
对我来说,解决方案是从仅使用以下注释的模块中的
kotlin-kapt
文件中删除 dagger.hilt.android.plugin
和 build.gradle
:
dagger.hilt.android.qualifiers
包(@ApplicationContext
等)javax.inject
包(@Inject
、@Singleton
等)plugins {
alias(libs.plugins.com.android.library)
alias(libs.plugins.kotlin.android)
// ⬇️ remove these 2 plugins
id('dagger.hilt.android.plugin')
id('kotlin-kapt')
// ⬆️
}
dependencies {
// …
// leave it here to use @Inject or replace with javax.inject dependency
implementation "com.google.dagger:hilt-android"
// remove only this ⬇️
kapt "com.google.dagger:hilt-android-compiler"
}