Dagger Hilt错误:app:hiltJavaCompileDebug

huangapple go评论94阅读模式
英文:

Dagger Hilt Error : app:hiltJavaCompileDebug

问题

以下是代码部分不需要翻译的内容:

Task :app:hiltJavaCompileDebug error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModuleComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)
=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityRetainedC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityRetainedC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.FragmentC' because 'dagger.hilt.android.internal.lifecycle.DefaultFragmentViewModelFactory' could not be resolved.

Dagger Hilt Version: 2.42
Kotlin Version: 1.7.0
Gradle Version: 7.4.1

what is the cause for this error?

I've used Dagger hilt as a Dependency injection framework in my project with version 2.42. In hilt_aggregated_deps all Components were generated but still I get hiltJavaCompileDebug : failed in Build.

I have also added below dependency to fix metadata but still the error is same.

dependencies {//Not a processor, but forces Dagger to use newer metadata libkapt "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.4.2"}reffering from [https://stackoverflow.com/questions/73061190/dagger-hilt-error-while-compiling-project\]

英文:

Task :app:hiltJavaCompileDebug error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModuleComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)
=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityRetainedC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityRetainedC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.ActivityC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.

Dependency trace:=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory

If type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' is on your classpath.error: ComponentProcessingStep was unable to process 'dev.kevalkanpariya.featuretesteduco.EduCoApplication_HiltComponents.FragmentC' because 'dagger.hilt.android.internal.lifecycle.DefaultFragmentViewModelFactory' could not be resolved.

Dagger Hilt Version: 2.42Kotlin Version: 1.7.0Gradle Version: 7.4.1

what is the cause for this error?

I've used Dagger hilt as a Dependency injection framework in my project with version 2.42. In hilt_aggregated_deps all Components were generated but still I get hiltJavaCompileDebug : failed in Build.

I have also added below dependency to fix metadata but still the error is same.

dependencies {//Not a processor, but forces Dagger to use newer metadata libkapt "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.4.2"}reffering from [https://stackoverflow.com/questions/73061190/dagger-hilt-error-while-compiling-project\]

答案1

得分: 1

代码部分不需要翻译,以下是翻译好的部分:

"The reason being that is from your hilt life"

"try to remove this:

implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03""

"Hmm, the androidx.hilt:hilt-lifecycle-viewmodel artifacts were deprecated in the Dagger 2.34 release in favor of native Hilt API. The missing DefaultActivityViewModelFactory class is no longer in the Hilt codebase."

"You should be able to fix this using the instructions in the 2.34 release notes to upgrade to the new HiltViewModel API. Find it here"

"Just by add these lines:

def hilt = "2.45"
implementation "com.google.dagger:hilt-android:$hilt"
kapt "com.google.dagger:hilt-android-compiler:$hilt""

英文:

The reason being that is from your hilt life

try to remove this:

implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"

> Hmm, the androidx.hilt:hilt-lifecycle-viewmodel artifacts were deprecated in the Dagger 2.34 release in favor of native Hilt API. The missing DefaultActivityViewModelFactory class is no longer in the Hilt codebase.
>
> You should be able to fix this using the instructions in the 2.34
> release notes to upgrade to the new HiltViewModel API.
Find it here

Just by add these line :

def hilt = "2.45"
implementation "com.google.dagger:hilt-android:$hilt"
kapt "com.google.dagger:hilt-android-compiler:$hilt"

huangapple
  • 本文由 发表于 2023年3月9日 20:06:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75684384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定