You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgrading Hilt version from 1.0.0 to 1.1.0 (dagger hilt android from 2.45 to 2.50). We have a custom Activity that we inherit from that is final, but Hilt generates code that overrides these methods and compiling doesn't work.
error: onDestroy() in Hilt_MainActivity cannot override onDestroy() in AppCompatCuustomActivity public final void onDestroy() { ^ overridden method is final 2 errors
Generated Code:
@CallSuper
@Override
public final void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initSavedStateHandleHolder();
}
@Override
public final void onDestroy() {
super.onDestroy();
if (savedStateHandleHolder != null) {
savedStateHandleHolder.clear();
}
}
The text was updated successfully, but these errors were encountered:
caltseng
changed the title
Hilt 1.1.0: Activity onCreate() and onDestroy() code is generated, but our base Activity class has these final
Dagger-Hilt 2.49: Activity onCreate() and onDestroy() code is generated, but our base Activity class has these final
Jan 2, 2024
Hi, Caleb, we had to override the lifecycle methods in order to lazily provide SavedStateHandle, I'll try to improve the error message, do you have to use final for those methods?
Let me follow up to see if we can get our own custom activity to remove final. I have a suspicion those were added a long time ago and is now obsolete. It's honestly also a bit of an antipattern anyways.
@wanyingd1996 - We removed final from our base Activity classes. Can probably close this out. (That said, still wondering if there's another pattern of implementation that could avoid this, but probably another conversation to be had if this is a more common issue)
Upgrading Hilt version from 1.0.0 to 1.1.0 (dagger hilt android from 2.45 to 2.50). We have a custom Activity that we inherit from that is final, but Hilt generates code that overrides these methods and compiling doesn't work.
Edit - looks like this was added in 2.49, PR
Error message:
error: onDestroy() in Hilt_MainActivity cannot override onDestroy() in AppCompatCuustomActivity public final void onDestroy() { ^ overridden method is final 2 errors
Generated Code:
The text was updated successfully, but these errors were encountered: