今天早上我切换到 Hilt 依赖注入(inject)。一切都完成后,我坚持这个:
error: cannot find symbol return DaggerMyApplication_HiltComponents_SingletonC.builder() ^ symbol: variable DaggerMyApplication_HiltComponents_SingletonC
我确实尝试自己找到解决方案,但我找到了 this one ,但我已经添加了所有模块的 build.gradle
如果我做错了什么,请看看我的。
我的应用程序:
@HiltAndroidApp
class MyApplication : MultiDexApplication()
项目分级:dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.34-beta'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
应用 Gradle :implementation 'com.google.dagger:hilt-android:2.34-beta'
kapt 'com.google.dagger:hilt-compiler:2.34-beta'
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt 'androidx.hilt:hilt-compiler:1.0.0-beta01'
谢谢你们
最佳答案
在我的情况下,这个错误是由 androidx.hilt:hilt-lifecycle-viewmodel
引起的依赖
根据 Dagger Hilt Github 评论:
implementation "androidx.hilt:hilt-lifecycle-viewmodel"
kapt "androidx.hilt:hilt-compiler"
应该被删除。见 this , 还有 this
关于android - 找不到符号返回 DaggerApplication_HiltComponents_SingletonC.builder(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67046457/