我有一个关于匕首刀柄的Jetpack的项目。一切正常,直到我在我的build.gradle文件中添加了实现“androidx.compose.runtime:runtime-livedata:1.6.0-alpha 03”依赖项。IDE会给出类似这样的错误:
致命异常:主要
Process: com.urahimli.asdf, PID: 3702
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/PrimitiveSnapshotStateKt;
我的build.gradle(模块)文件:
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
}
我发现这个错误发生在有一些版本问题时。请帮助我解决这个问题。
1条答案
按热度按时间kognpnkq1#
编写运行时库在1.6.0-alpha 04版本上有错误。使用稳定版本或减少alpha版本将解决问题。
查看此链接:https://developer.android.com/jetpack/androidx/releases/compose-runtime