Jetpack Compose中SAVED_STATE_REGISTRY_OWNER_KEY错误原因排查
排查Jetpack Compose结合Clean Architecture开发时的
SAVED_STATE_REGISTRY_OWNER_KEY错误 出现的错误:
java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY`
项目级Gradle配置
buildscript { ext { compose_ui_version = '1.1.1' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '7.3.1' apply false id 'com.android.library' version '7.3.1' apply false id 'org.jetbrains.kotlin.android' version '1.6.10' apply false id 'com.google.dagger.hilt.android' version '2.44' apply false }
模块级Gradle配置
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'kotlin-kapt' id 'dagger.hilt.android.plugin' } android { namespace 'com.example.kotlinretrofit' compileSdk 33 defaultConfig { applicationId "com.example.kotlinretrofit" minSdk 24 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary true } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } buildFeatures { compose true } composeOptions { kotlinCompilerExtensionVersion '1.1.1' } packagingOptions { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' } } } dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' implementation 'androidx.activity:activity-compose:1.3.1' implementation "androidx.compose.ui:ui:$compose_ui_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" implementation 'androidx.compose.material:material:1.1.1' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version" // Retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation "com.squareup.okhttp3:okhttp:4.9.3" implementation "com.squareup.okhttp3:logging-interceptor:4.9.0" implementation "androidx.compose.runtime:runtime-livedata:1.4.0-alpha04" // Coroutines implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' // Coroutine Lifecycle Scopes implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" // Hilt implementation "com.google.dagger:hilt-android:2.44" kapt "com.google.dagger:hilt-compiler:2.44" }
问题说明
使用Jetpack Compose结合Clean Architecture开发网络应用时触发上述错误,推测问题与依赖相关,所用依赖来自10天前的教程视频,已尝试调整Gradle版本但无效,请求排查错误原因。
内容的提问来源于stack exchange,提问作者Kring Lord
相关产品推荐
相关产品推荐

