google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.43k stars 2.01k forks source link

Compilation issues after moving to 2.34 from 2.33 - Hilt #2541

Closed C0deWithAj closed 3 years ago

C0deWithAj commented 3 years ago

Our production app was successfully using 2.33 dagger until this morning we moved to 2.34 and started getting compilation issues and the code is not building.

Looks like the errors are from "DefaultViewModelFactories" and "DaggerAppControl_HiltComponents_SingletonC" . The following error points to my Application class: "error: cannot find symbol return DaggerAppControl_HiltComponents_SingletonC.builder()"

Anybody having similar issues after moving to 2.34 ?

bcorso commented 3 years ago

Hi @Ajmalajji,

Looks like the errors are from "DefaultViewModelFactories" and "DaggerAppControl_HiltComponents_SingletonC" .

What are the errors from DefaultViewModelFactories? Are there any other errors? Typically, the error you posted with DaggerAppControl_HiltComponents_SingletonC is just a side effect of the real issue, which is that Dagger did not generate the component, so we would need to figure out why Dagger did not generate the component.

ReginFell commented 3 years ago

We have the same issue in our project, the logs we have

error: [Hilt]
  Null dependency: java.lang.NullPointerException: Null dependency

Everything is working fine in 2.33

mak1nt0sh commented 3 years ago

Same issue when moving 2.33 -> 2.34

error: cannot access DefaultActivityViewModelFactory class file for dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory not found Consult the following stack trace for details. com.sun.tools.javac.code.Symbol$CompletionFailure: class file for dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory not found

bcorso commented 3 years ago

Ah, thanks for the details. The DefaultActivityViewModelFactory was removed in Dagger 2.34. It was previously used with the androidx.hilt library for @ViewModelInject which was deprecated in androidx.hilt 1.0.0-alpha03 and removed in androidx.hilt 1.0.0-beta01. View model injection is now supported natively in Hilt via @HiltViewModel.

You can find more details in the Dagger 2.34 release notes, and I've just updated the release notes with a section to help migration from @ViewModelInject to @HiltViewModel.

mak1nt0sh commented 3 years ago

Fixed by removing deprecated dependencies: implementation "androidx.hilt:hilt-lifecycle-viewmodel" kapt "androidx.hilt:hilt-compiler

shirajsayed13 commented 3 years ago

I am facing issue after adding this paging3 dependency implementation 'androidx.paging:paging-common-ktx:3.0.1' implementation 'androidx.paging:paging-runtime-ktx:3.0.1'