Comments (7)
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 dataSize()
in any of our generated code, but would need the whole stacktrace to know more. Also, IllegalArgumentException by itself with no stack is very hard to know what is going on there.
from dagger.
Sure @Chang-Eric , these are the stack traces:
// Case 1
Fatal Exception: java.lang.IllegalArgumentException:
at android.os.Parcel.nativeAppendFrom(Parcel.java)
at android.os.Parcel.appendFrom(Parcel.java:453)
at android.os.BaseBundle.<init>(BaseBundle.java:126)
at android.os.Bundle.<init>(Bundle.java:102)
at android.content.Intent.getExtras(Intent.java:5724)
at androidx.activity.ComponentActivity.getDefaultViewModelProviderFactory(ComponentActivity.java:654)
at com.myapp.android.splash.Hilt_SplashScreen.getDefaultViewModelProviderFactory(Hilt_SplashScreen.java:75)
at androidx.activity.ActivityViewModelLazyKt$viewModels$factoryPromise$2.invoke(ActivityViewModelLazy.kt:80)
at com.myapp.android.splash.SplashScreen$special$$inlined$viewModels$default$1.invoke(ActivityViewModelLazy.kt:80)
at com.myapp.android.splash.SplashScreen$special$$inlined$viewModels$default$1.invoke(ActivityViewModelLazy.kt:79)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:47)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
at com.myapp.android.splash.SplashScreen.getViewModel(SplashScreen.kt:18)
at com.myapp.android.splash.SplashScreen.access$getViewModel(SplashScreen.kt:14)
at com.myapp.android.splash.SplashScreen$onCreate$2.invokeSuspend(SplashScreen.kt:27)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.java:110)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(BuildersKt__Builders_common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Builders.kt:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(BuildersKt__Builders_common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Builders.kt:1)
at com.myapp.android.splash.SplashScreen.onCreate(SplashScreen.kt:26)
at android.app.Activity.performCreate(Activity.java:6351)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1114)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1414)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5619)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737)
// Case 2
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Parcel.dataSize()' on a null object reference
at android.os.BaseBundle.<init>(BaseBundle.java:164)
at android.os.Bundle.<init>(Bundle.java:106)
at android.content.Intent.getExtras(Intent.java:7186)
at androidx.activity.ComponentActivity.getDefaultViewModelProviderFactory(ComponentActivity.java:654)
at com.myapp.android.splash.Hilt_SplashScreen.getDefaultViewModelProviderFactory(Hilt_SplashScreen.java:75)
at androidx.activity.ActivityViewModelLazyKt$viewModels$factoryPromise$2.invoke(ActivityViewModelLazy.kt:80)
at com.myapp.android.splash.SplashScreen$special$$inlined$viewModels$default$1.invoke(ActivityViewModelLazy.kt:80)
at com.myapp.android.splash.SplashScreen$special$$inlined$viewModels$default$1.invoke(ActivityViewModelLazy.kt:79)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:47)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
at com.myapp.android.splash.SplashScreen.getViewModel(SplashScreen.kt:18)
at com.myapp.android.splash.SplashScreen.access$getViewModel(SplashScreen.kt:14)
at com.myapp.android.splash.SplashScreen$onCreate$2.invokeSuspend(SplashScreen.kt:27)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.java:110)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(BuildersKt__Builders_common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Builders.kt:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(BuildersKt__Builders_common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Builders.kt:1)
at com.myapp.android.splash.SplashScreen.onCreate(SplashScreen.kt:26)
at android.app.Activity.performCreate(Activity.java:6977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6816)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1453)
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).
from dagger.
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 getDefaultViewModelProviderFactory
method which means it would happen without Hilt as well. It looks like something in the Intent extras is malformed? I'm not really sure beyond that though.
from dagger.
Hello have you found any solution I get these exact crashes too.
from dagger.
@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 @AndroidEntryPoint
. In our case, the stack trace always include a reference to generated dagger.hilt.android.internal
code - see stacktrace below. Let me know if you need further information
Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'int android.os.Parcel.dataSize()' on a null object reference
android.os.BaseBundle.<init> (BaseBundle.java:126)
android.os.Bundle.<init> (Bundle.java:102)
android.content.Intent.getExtras (Intent.java:6569)
androidx.activity.ComponentActivity.getDefaultViewModelCreationExtras (ComponentActivity.java:655)
androidx.lifecycle.ViewModelProviderGetKt.defaultCreationExtras (ViewModelProvider.kt:359)
androidx.lifecycle.ViewModelProvider.<init> (ViewModelProvider.kt:129)
dagger.hilt.android.internal.managers.ActivityRetainedComponentManager.getViewModelProvider (ActivityRetainedComponentManager.java:100)
dagger.hilt.android.internal.managers.ActivityRetainedComponentManager.getSavedStateHandleHolder (ActivityRetainedComponentManager.java:134)
dagger.hilt.android.internal.managers.ActivityComponentManager.getSavedStateHandleHolder (ActivityComponentManager.java:76)
com.app.android.presentation.Hilt_DetailActivity.initSavedStateHandleHolder (Hilt_DetailActivity.java:53)
com.app.android.presentation.Hilt_DetailActivity.onCreate (Hilt_DetailActivity.java:64)
com.app.android.presentation.DetailActivity.onCreate (DetailActivity.kt:68)
android.app.Activity.performCreate (Activity.java:6904)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1136)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3266)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3415)
android.app.ActivityThread.access$1100 (ActivityThread.java:229)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1821)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:7406)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
from dagger.
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!
from dagger.
@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 onCreate()
, even after super.onCreate()
, which we know shouldn't be the case. So that's why this doesn't seem like a lifecycle issue in the generated code to me.
from dagger.
Related Issues (20)
- error when ksp.useKSP2=true HOT 2
- Suppress annotation on @Inject is not honored on the Factory HOT 1
- [KSP2] Dagger and Hilt incompatibility with KSP2 HOT 4
- [KSP2] NullPointerException: null cannot be cast to non-null type androidx.room.compiler.processing.XType HOT 1
- App crashing with NPE for some classes when Lazy Class Key is used HOT 7
- OutOfMemoryError with Maven HOT 1
- DaggerAppComponent not creating in the version 2.51.1 HOT 3
- java.lang.ClassNotFoundException: dagger.spi.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor. Hilt 2.49+ HOT 1
- how to manually generate module HOT 1
- Explain how to add dagger jar files manually to the android project HOT 2
- Annotate interface with default Bind implementation HOT 2
- Transitive vulnerability from symbol-processing-api HOT 1
- java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY` HOT 4
- Update of different dependency: Error "package javax.annotation.processing is not visible" HOT 4
- Compile time error with KSP with Generics HOT 4
- java.lang.IllegalArgumentException: Multiple entries with same key HOT 4
- Execution failed for task ':app:kaptDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message) HOT 2
- Stackoverflow when exposing parents of Subcomponents HOT 7
- Hilt not working with android testFixtures? HOT 2
- Hilt 2.44.2 - Class not found when use @AndroidEntryPoint at WidgetReceiver HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.