Skip to content

java.lang.IllegalArgumentException: CreationExtras must have a value by SAVED_STATE_REGISTRY_OWNER_KEY #4320

Open

Description

When running project that has HILT, I am getting the following crash caused by:

val createReceiptViewModel: CreateReceiptViewModel = hiltViewModel<CreateReceiptViewModel>(key = "create_bill_viewmodel")

on the stacktrace:

FATAL EXCEPTION: main
Process: com.rowland.spendysync, PID: 9814
java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY`
at androidx.lifecycle.SavedStateHandleSupport.createSavedStateHandle(SavedStateHandleSupport.kt:89)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$2.create(HiltViewModelFactory.java:100)
at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:170)
at androidx.lifecycle.ViewModelProvider$Factory.create(ViewModelProvider.android.kt:158)

Dependencies:

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.8.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.1"

implementation "androidx.navigation:navigation-ui-ktx:2.8.0-beta02"
implementation "androidx.navigation:navigation-compose:2.8.0-beta02"

implementation "com.google.dagger:hilt-android:2.51.1"
ksp "com.google.dagger:hilt-android-compiler:2.51.1"
implementation "androidx.hilt:hilt-navigation-compose:1.2.0"

This issue only happens when I try to consume a library that is compiled with KMP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions