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
but I noticed that the ViewModel injection fails and causes a crash with stacktrace as below, however upon removing the exceptionHandler the app runs without a crash java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Factory: 'profile_presentation.EditProfileViewModel']' at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:58) at org.koin.core.instance.FactoryInstanceFactory.get(FactoryInstanceFactory.kt:38) at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:110) at org.koin.core.scope.Scope.resolveFromRegistry(Scope.kt:321) at org.koin.core.scope.Scope.resolveFromContext(Scope.kt:311) at org.koin.core.scope.Scope.stackParametersCall(Scope.kt:281) at org.koin.core.scope.Scope.resolveInstance(Scope.kt:259) at org.koin.core.scope.Scope.resolveWithOptionalLogging(Scope.kt:232) at org.koin.core.scope.Scope.get(Scope.kt:215) at org.koin.viewmodel.factory.KoinViewModelFactory.create(KoinViewModelFactory.kt:39) at androidx.lifecycle.viewmodel.ViewModelProviderImpl_androidKt.createViewModel(ViewModelProviderImpl.android.kt:34) at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release(ViewModelProviderImpl.kt:65) at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release$default(ViewModelProviderImpl.kt:47) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:91) at org.koin.viewmodel.GetViewModelKt.resolveViewModel(GetViewModel.kt:60) at org.koin.viewmodel.GetViewModelKt.resolveViewModel$default(GetViewModel.kt:44 at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3152) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:608) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2214) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2115) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2052) at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:703) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8705) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object kotlin.coroutines.CoroutineContext.fold(java.lang.Object, kotlin.jvm.functions.Function2)' on a null object reference at kotlinx.coroutines.CoroutineContextKt.hasCopyableElements(CoroutineContext.kt:36) at kotlinx.coroutines.CoroutineContextKt.foldCopies(CoroutineContext.kt:51) 2024-12-16 19:25:17.004 13141-13141 AndroidRuntime E at kotlinx.coroutines.CoroutineContextKt.newCoroutineContext(CoroutineContext.kt:15) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:48) at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:43) at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1) at at presentation.di.FeatureProfileModulesKt.viewModelModules$lambda$1$lambda$0(FeatureProfileModules.kt:9) at presentation.di.FeatureProfileModulesKt.$r8$lambda$I4C-DS2Jr0O4j89h8zyZwNHL4z8(Unknown Source:0) at presentation.di.FeatureProfileModulesKt$$ExternalSyntheticLambda2.invoke(D8$$SyntheticClass:0) at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:51)
To Reproduce
Steps to reproduce the behavior:
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
The app should not crash and koin should be able to create an instance of the viewmodel
Koin module and version:
[e.g]: koin-android:4.0.0
Snippet or Sample project to help reproduce
Add a snippet or even a small sample project to help reproduce your case.
The text was updated successfully, but these errors were encountered:
Describe the bug
In my ViewModel i use need to specify an exception handler when launching a coroutine in viewModelScope as below
kotlin private val exceptionHandler = CoroutineExceptionHandler { _, throwable -> } viewModelScope.launch(exceptionHandler) { //code }
but I noticed that the ViewModel injection fails and causes a crash with stacktrace as below, however upon removing the exceptionHandler the app runs without a crash
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Factory: 'profile_presentation.EditProfileViewModel']' at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:58) at org.koin.core.instance.FactoryInstanceFactory.get(FactoryInstanceFactory.kt:38) at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:110) at org.koin.core.scope.Scope.resolveFromRegistry(Scope.kt:321) at org.koin.core.scope.Scope.resolveFromContext(Scope.kt:311) at org.koin.core.scope.Scope.stackParametersCall(Scope.kt:281) at org.koin.core.scope.Scope.resolveInstance(Scope.kt:259) at org.koin.core.scope.Scope.resolveWithOptionalLogging(Scope.kt:232) at org.koin.core.scope.Scope.get(Scope.kt:215) at org.koin.viewmodel.factory.KoinViewModelFactory.create(KoinViewModelFactory.kt:39) at androidx.lifecycle.viewmodel.ViewModelProviderImpl_androidKt.createViewModel(ViewModelProviderImpl.android.kt:34) at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release(ViewModelProviderImpl.kt:65) at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release$default(ViewModelProviderImpl.kt:47) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:91) at org.koin.viewmodel.GetViewModelKt.resolveViewModel(GetViewModel.kt:60) at org.koin.viewmodel.GetViewModelKt.resolveViewModel$default(GetViewModel.kt:44 at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3152) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:608) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2214) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2115) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2052) at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:703) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8705) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object kotlin.coroutines.CoroutineContext.fold(java.lang.Object, kotlin.jvm.functions.Function2)' on a null object reference at kotlinx.coroutines.CoroutineContextKt.hasCopyableElements(CoroutineContext.kt:36) at kotlinx.coroutines.CoroutineContextKt.foldCopies(CoroutineContext.kt:51) 2024-12-16 19:25:17.004 13141-13141 AndroidRuntime E at kotlinx.coroutines.CoroutineContextKt.newCoroutineContext(CoroutineContext.kt:15) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:48) at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:43) at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1) at at presentation.di.FeatureProfileModulesKt.viewModelModules$lambda$1$lambda$0(FeatureProfileModules.kt:9) at presentation.di.FeatureProfileModulesKt.$r8$lambda$I4C-DS2Jr0O4j89h8zyZwNHL4z8(Unknown Source:0) at presentation.di.FeatureProfileModulesKt$$ExternalSyntheticLambda2.invoke(D8$$SyntheticClass:0) at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:51)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The app should not crash and koin should be able to create an instance of the viewmodel
Koin module and version:
[e.g]:
koin-android:4.0.0
Snippet or Sample project to help reproduce
Add a snippet or even a small sample project to help reproduce your case.
The text was updated successfully, but these errors were encountered: