java.lang.ClassNotFoundException:未找到类“androidx.compose.runtime.PrimitiveSnapshotStateKt”

java.lang.ClassNotFoundException: Didn't find class "androidx.compose.runtime.PrimitiveSnapshotStateKt"

提问人:Marco Portacio 提问时间:9/18/2023 最后编辑:Marco Portacio 更新时间:9/18/2023 访问量:373

问:

我目前正在开发一个任务管理器应用程序。但是,当应用程序处于调试变体中时,一切正常运行并且编译没有问题。但是当我切换到发布变体时,我在 Firebase Crashlytics 中收到此错误日志,并且应用程序在启动时崩溃。

Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/PrimitiveSnapshotStateKt;
       at androidx.compose.animation.EnterExitTransitionKt.<clinit>(EnterExitTransition.kt:12)
       at androidx.compose.animation.EnterExitTransitionKt.fadeIn$default(EnterExitTransition.kt)
       at androidx.navigation.compose.NavHostKt$NavHost$3.invoke(NavHost.kt:13)
       at androidx.navigation.compose.NavHostKt$NavHost$3.invoke(NavHost.kt:13)
       at androidx.navigation.compose.NavHostKt$NavHost$finalEnter$1$1.invoke(NavHost.kt:155)
       at androidx.navigation.compose.NavHostKt$NavHost$finalEnter$1$1.invoke(NavHost.kt:155)
       at androidx.navigation.compose.NavHostKt$NavHost$12.invoke(NavHost.kt:339)
       at androidx.navigation.compose.NavHostKt$NavHost$12.invoke(NavHost.kt:339)
       at androidx.compose.animation.AnimatedContentKt.AnimatedContent(AnimatedContent.kt:688)
       at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:2100)
       at androidx.navigation.compose.NavHostKt$NavHost$16.invoke(NavHost.kt:80)
       at androidx.navigation.compose.NavHostKt$NavHost$16.invoke(NavHost.kt:28)
       at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.java:281)
       at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(ComposerImpl.java:281)
       at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(ComposerImpl.java:57)
       at androidx.compose.runtime.ComposerImpl.doCompose(ComposerImpl.java:166)
       at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(ComposerImpl.java:30)
       at androidx.compose.runtime.CompositionImpl.recompose(CompositionImpl.java:21)
       at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.java:111)
       at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.java:111)
       at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.java:399)
       at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.java:399)
       at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.java:6)
       at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.java:47)
       at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.java:47)
       at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.java:47)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1090)
       at android.view.Choreographer.doCallbacks(Choreographer.java:893)
       at android.view.Choreographer.doFrame(Choreographer.java:809)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1078)
       at android.os.Handler.handleCallback(Handler.java:907)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:216)
       at android.app.ActivityThread.main(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

这是我的build.gradle.kts:app文件:

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.dagger.hilt.android")
    id("com.google.devtools.ksp")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}

android {
    namespace = "com.example.dayminder"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.dayminder"
        minSdk = 26
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
            isShrinkResources = true
            isDebuggable = false
        }
        debug {
            isDebuggable = true
            isMinifyEnabled = false
            isShrinkResources = false
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        buildConfig = true
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.0"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

dependencies {

    val composeBomVersion = "2023.09.00"
    val roomVersion = "2.5.2"
    val daggerHiltVersion = "2.48"
    val composeNavigationVersion = "2.7.2"
    val hiltNavigationComposeVersion = "1.0.0"
    val lifecycleRuntimeComposeVersion = "2.6.2"
    val timberVersion = "5.0.1"
    val loggerVersion = "2.2.0"
    val lottieComposeVersion = "6.1.0"
    val systemUiControllerVersion = "0.33.1-alpha"
    val firebaseBomVersion = "32.3.1"
    val splashScreenApiVersion = "1.0.1"

    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("androidx.activity:activity-compose:1.7.2")
    implementation(platform("androidx.compose:compose-bom:$composeBomVersion"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-graphics")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.material3:material3")

    //Room
    implementation("androidx.room:room-ktx:$roomVersion")
    ksp("androidx.room:room-compiler:$roomVersion")

    //Dagger Hilt
    implementation("com.google.dagger:hilt-android:$daggerHiltVersion")
    ksp("com.google.dagger:hilt-android-compiler:$daggerHiltVersion")

    //Navigation
    implementation("androidx.navigation:navigation-compose:$composeNavigationVersion")

    //Hilt Navigation Compose
    implementation("androidx.hilt:hilt-navigation-compose:$hiltNavigationComposeVersion")

    //Lifecycle runtime
    implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycleRuntimeComposeVersion")

    //Timber
    implementation("com.jakewharton.timber:timber:$timberVersion")

    //Logger
    implementation("com.orhanobut:logger:$loggerVersion")

    //Lottie
    implementation("com.airbnb.android:lottie-compose:$lottieComposeVersion")

    //System UI Controller
    implementation("com.google.accompanist:accompanist-systemuicontroller:$systemUiControllerVersion")

    //Firebase
    //Bom
    // Import the BoM for the Firebase platform
    implementation(platform("com.google.firebase:firebase-bom:$firebaseBomVersion"))
    //Analytics
    implementation("com.google.firebase:firebase-analytics-ktx")
    //Crashlytics
    implementation("com.google.firebase:firebase-crashlytics-ktx")

    //Splash screen API
    implementation("androidx.core:core-splashscreen:$splashScreenApiVersion")


    //Test dependencies
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    androidTestImplementation(platform("androidx.compose:compose-bom:$composeBomVersion"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")
}

这是 build.gradle:project 文件:

plugins {
    id("com.android.application") version "8.1.1" apply false
    id("org.jetbrains.kotlin.android") version "1.9.0" apply false
    id("com.google.dagger.hilt.android") version "2.44" apply false
    id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false
}

buildscript {
    dependencies {
        classpath("com.google.dagger:hilt-android-gradle-plugin:2.48")
        classpath("com.google.gms:google-services:4.4.0")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9")
    }
}

拜托,我需要尽快解决。由于这个烦人的问题,我无法在 Play 商店中启动该应用程序。

我尝试降级撰写 bom 版本,但没有用。

Android Kotlin 异常 android-jetpack-compose proguard

评论

0赞 Marco Portacio 9/18/2023
我找到了解决方案,基本上库 systemUiController 被弃用了,当我删除它时,一切正常。
0赞 Ayushi Khandelwal 9/18/2023
嘿@Marco,我关注了 github.com/android/nowinandroid/pull/817/files,但我仍然收到此错误。你能分享一下什么对你有用吗?
0赞 Marco Portacio 9/22/2023
嗨,我刚刚从我的代码和我的 build.gradle:app 依赖项中删除了 systemUI 控制器的所有用法

答: 暂无答案