6

I am getting this error multiple times in all my Jetpack compose projects. Is this error an issue related to the Gradle? Because I have not changed anything to the Theme.

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)

Logs

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 -Project

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
}

gradle\wrapper\gradle-wrapper.properties

Sweta Jain
  • 3,248
  • 6
  • 30
  • 50

3 Answers3

1

Try to update your compose version to the latest if you see such error. java.lang.NoSuchFieldError: No field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion;

Tink
  • 586
  • 7
  • 10
0

If you use binding and change component from XML for example if you add Button after that changed to EditText It will through that exception. Just you need to do rebuild.

0

I had a similar issue, but after updating all AndroidX libraries to the latest, the issue was gone.

imodeGowas
  • 35
  • 10