Android Compose-Navigation 2.4.0-alpha2 因 NoSuchMethodError 崩溃 [英] Android Compose-Navigation 2.4.0-alpha2 crashes with NoSuchMethodError

查看:34
本文介绍了Android Compose-Navigation 2.4.0-alpha2 因 NoSuchMethodError 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新撰写导航依赖项的版本后,我的应用程序在启动时直接崩溃,出现以下异常:

After updating the version of the compose navigation dependency, my app crashes directly at launch with the following Exception:

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)
...

当使用旧版本时,我得到这个 问题

When using an older version I get the Exception described in this question

您有什么想法,可能导致此问题的原因是什么?这些是我的依赖项 (compose_version = '1.0.0-beta07')

Do you have an idea, what might cause this problem? These are my dependencies (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"

}

推荐答案

你可以试试 1.0.0-beta09 并将 Kotlin 编译器更新到 1.5.10,这个配置

you can try with 1.0.0-beta09 and update Kotlin compiler to 1.5.10, this configuration

    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "1.0.0-beta08"
    }
}

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.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    

    // Compose
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.0.0-beta08"
    implementation "androidx.activity:activity-compose:1.3.0-beta02"
    implementation "androidx.compose.runtime:runtime:1.0.0-beta09"
    implementation "androidx.compose.ui:ui:1.0.0-beta09"
    implementation "androidx.compose.foundation:foundation:1.0.0-beta09"
    implementation "androidx.compose.foundation:foundation-layout:1.0.0-beta09"
    implementation "androidx.compose.material:material:1.0.0-beta09"
    implementation "androidx.compose.runtime:runtime-livedata:1.0.0-beta09"
    implementation "androidx.compose.ui:ui-tooling:1.0.0-beta09"
    implementation "com.google.android.material:compose-theme-adapter:1.0.0-beta09"
}

这篇关于Android Compose-Navigation 2.4.0-alpha2 因 NoSuchMethodError 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆