Swe*_*ain 6 android-studio android-jetpack material-components-android android-jetpack-navigation android-jetpack-compose
我在所有 Jetpack compose 项目中多次收到此错误。这个错误是否与 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)
Run Code Online (Sandbox Code Playgroud)
应用程序.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'
}
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
如果您看到此类错误,请尝试将您的 compose 版本更新到最新版本。 java.lang.NoSuchFieldError:没有 Landroidx/compose/foundation/layout/BoxScope$Companion 类型的字段 Companion;
| 归档时间: |
|
| 查看次数: |
3052 次 |
| 最近记录: |