【发布时间】:2021-06-04 12:07:29
【问题描述】:
更新撰写导航依赖项的版本后,我的应用程序在启动时直接崩溃,并出现以下异常:
java.lang.NoSuchMethodError: No static method drawRect-w2WG-Gw$default(Landroidx/compose/ui/graphics/drawscope/DrawScope;JJJFLandroidx/compose/ui/graphics/drawscope/DrawStyle;Landroidx/compose/ui/graphics/ColorFilter;Landroidx/compose/ui/graphics/BlendMode;ILjava/lang/Object;)V in class Landroidx/compose/ui/graphics/drawscope/DrawScope$DefaultImpls; or its super classes (declaration of 'androidx.compose.ui.graphics.drawscope.DrawScope$DefaultImpls' appears in /data/app/~~pBKRwWSGSd6Trycrlz_8bw==/com.example.wunderguard-9YsObT0GJC9oUzrTLizqog==/base.apk)
at androidx.compose.foundation.Background.drawRect(Background.kt:111)
at androidx.compose.foundation.Background.draw(Background.kt:103)
...
当使用旧版本时,我得到了 question 中描述的异常
你有什么想法,什么可能导致这个问题? 这些是我的依赖项(compose_version = '1.0.0-beta07')
dependencies {
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.navigation:navigation-compose:2.4.0-alpha02"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation "androidx.activity:activity-compose:1.3.0-beta01"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
}
【问题讨论】:
-
确定问题出在 alpha2 中:D
-
可以试试 beta08 吗?
-
将 Compose 更新到 beta08 并将 Kotlin 更新到 1.5.10 后,它可以工作了!感谢您的提示,我没有意识到已经有 beta08:/
标签: android android-jetpack-compose