New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getViewModel crash intermittently with NullPointerException / IllegalArgumentException #4191
Comments
Are you able to provide more of the stacktrace? It is hard to tell what is going on. So far based on what I can see though, I have trouble imagining that this is something in Hilt. I don't think we call |
Sure @Chang-Eric , these are the stack traces:
additional info: Firebase tags it as "Early crashes", means it happens in the first 5 seconds when user open the app (I guess bcs it's splash screen). |
Thanks for the stacktraces. I don't think this is related to Hilt. These crashes are coming from when we call through to the Activity's |
Hello have you found any solution I get these exact crashes too. |
@Chang-Eric hello! we are experiencing this issue as well since some time ago in several of our activities and we were wondering if it has to do with a lifecycle issue between in the code that dagger generates for the activities annotated with
|
Hi, nico, do you get this error if you directly invoke getDefaultViewModelCreationExtras from DetailActivity#onCreate? If so, it should be a malformed intent problem, and cannot be fixed from Dagger side, thanks! |
@nico-gonzalez To my knowledge, a lifecycle issue wouldn't appear as intermittent because all of this is happening on the main thread (in your stacktrace this is happening in onCreate() which is on the main thread and if we were at the wrong time in the lifecycle, that lifecycle change we're missing would also be done on the main thread), so there wouldn't really be a race unless it were unsafe to access any ViewModels in |
I'm migrating Dagger 2 to Hilt (2.48.1) and applying
@AndroidEntryPoint
and@HiltViewModel
in my SplashScreen.In latest release, we got some crash reports in my screen:
All of them actually mention the same thing:
My SplashScreen is quite simple:
How can we resolve this intermittent crash in that SplashScreen?
I'm using kapt, AGP: 8.1.2, Kotlin: 1.9.10, Dagger & Hilt: 2.48.1, Java 17
And all of those crashes happen in Android 7 and 6 only (so far)
The text was updated successfully, but these errors were encountered: