Android Studio 如何解决java.lang.NoSuchFieldError:没有Landroidx/compose/runtime/SlotTable$Companion类型的字段配套?

zsbz8rwp  于 2023-01-26  发布在  Android
关注(0)|答案(2)|浏览(293)

我在所有Jetpack合成项目中多次收到此错误。此错误是否与Gradle相关?因为我没有对主题进行任何更改。

java.lang.NoSuchFieldError: No field Companion of type Landroidx/compose/runtime/SlotTable$Companion; in class Landroidx/compose/runtime/SlotTable; or its superclasses (declaration of 'androidx.compose.runtime.SlotTable' appears in /data/app/~~-cK_xmGsJokhf6B_7aQseg==/com.swetajain.library-CN37OSea3A4uAWXYCBb63w==/base.apk)

app.build.gradle

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.runtime:runtime:$compose_version"
    implementation "androidx.compose.foundation:foundation:$compose_version"
    implementation "androidx.compose.foundation:foundation-layout:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "com.google.android.material:compose-theme-adapter:$compose_version"
    api 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-beta01'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-beta01@aar'
    implementation 'androidx.activity:activity-ktx:1.2.0-beta01@aar'
    implementation "dev.chrisbanes.accompanist:accompanist-coil:0.3.3.1"
    def nav_compose_version = "1.0.0-alpha02"
    implementation "androidx.navigation:navigation-compose:$nav_compose_version"
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

build.gradle -项目

buildscript {

    ext.compose_version = '1.0.0-alpha04'
    ext.kotlin_version = "1.4.20"

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.0-alpha16"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ee7vknir

ee7vknir1#

如果看到此类错误,请尝试将合成版本更新为最新版本。java.lang.NoSuchFieldError:没有Landroidx/compose/foundation/layout/BoxScope$Companion类型的现场配套设备;

epggiuax

epggiuax2#

如果你使用绑定并从XML更改组件,例如,如果你在更改为EditText之后添加Button,它将通过该异常。只是你需要重新构建。

相关问题