解析失败:Landroidx/compose/runtime/PrimitiveSnapshotStateKt

3
我在Jetpack Compose和Dagger Hilt上有一个项目。一切都很好,直到我在我的build.gradle文件中添加了implementation "androidx.compose.runtime:runtime-livedata:1.6.0-alpha03"依赖项。IDE报错如下:
主要异常:
 Process: com.urahimli.asdf, PID: 3702
                                                                                                java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/PrimitiveSnapshotStateKt;

我的 build.gradle(module) 文件:
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id "com.google.dagger.hilt.android"
}

android {
    namespace 'com.urahimli.asdfg'
    compileSdk 34

    defaultConfig {
        applicationId "com.urahimli.asdfg"
        minSdk 26
        targetSdk 34
        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.3.2'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.10.1'
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation platform('androidx.compose:compose-bom:2022.10.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    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:2022.10.00')
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'


    // Compose dependencies
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
    implementation "androidx.navigation:navigation-compose:2.7.0"
    implementation "androidx.hilt:hilt-navigation-compose:1.1.0-alpha01"

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2'

    //Dagger - Hilt
    implementation 'com.google.dagger:hilt-android:2.46.1'
    kapt 'com.google.dagger:hilt-android-compiler:2.46.1'
    kapt "androidx.hilt:hilt-compiler:1.0.0"

    // Room
    implementation "androidx.room:room-runtime:2.5.2"
    kapt "androidx.room:room-compiler:2.5.2"

    // Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:2.5.2"

    //material 3
    implementation("androidx.compose.material3:material3:1.1.1")
    implementation "androidx.compose.material:material:1.5.0"
    implementation("androidx.compose.material:material-icons-extended:1.5.0")

    // coil for images
    implementation("io.coil-kt:coil-compose:2.4.0")

    // system ui controller (status bar)
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
    implementation "com.google.accompanist:accompanist-swiperefresh:0.28.0"

    // date picker
    implementation "io.github.vanpra.compose-material-dialogs:datetime:0.8.1-rc"
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'

    //
    implementation "androidx.compose.runtime:runtime-livedata:1.6.0-alpha03"

}

kapt {
    correctErrorTypes = true
}

我的 build.gradle(project) 文件如下:
plugins {
    id 'com.android.application' version '8.0.2' apply false
    id 'com.android.library' version '8.0.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false

    id("com.google.dagger.hilt.android") version "2.44" apply false
}

我发现这个错误是由于版本问题引起的。请帮我解决这个问题好吗?

嗨,可能是与此链接中描述的错误相同 https://dev59.com/DF4KtIcB2Jgan1znFB4p - undefined
嗨,是的,但那个链接是在2021年写的。我认为我通过删除这个实现 "androidx.compose.runtime:runtime-livedata:1.6.0-alpha03" 来修复了这个错误。 - undefined
请检查此链接:https://github.com/airbnb/lottie-android/issues/1773 - undefined
我解决了移除无用依赖的问题,感谢您的支持。 - undefined
1个回答

0

1
我正在使用 compose-runtime 1.5.0,但仍然遇到相同的错误。有任何想法吗? - undefined
1
请尝试使用1.6.0-alpha03和kotlinComposeCompiler = 1.5.2。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接