7

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

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"

}

3
  • For sure the problem is in alpha2 :D Commented Jun 4, 2021 at 12:12
  • Can you try with beta08? Commented Jun 4, 2021 at 12:28
  • After Updating Compose to beta08 and Kotlin to 1.5.10 it works! Thanks for the hint I didn't realise there was a beta08 already :/ Commented Jun 4, 2021 at 13:06

4 Answers 4

15

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"
}
Sign up to request clarification or add additional context in comments.

1 Comment

After Updating Compose to beta08 and Kotlin to 1.5.10 it works! Thanks for the hint I didn't realise there was a beta08 already...
4

The version androidx.navigation:navigation-compose:2.4.0-alpha02 contains this commit:

Upgrade to Kotlin 1.5.0, KSP to 1.5.0-1.0.0-alpha09

  • Update your compose dependencies to 1.0.0-beta08
  • Update Kotlin compiler to 1.5.10

Comments

0

Do you read your posted link? java.lang.NoSuchMethodError after upgrading Jetpack Compose to 1.0.0‑beta07? Obviouse that you have to use the same version for all compose libs.

1 Comment

androidx.navigation:navigation-compose is not available in beta. Accordig to (developer.android.com/jetpack/androidx/releases/…) it should work with compose beta 07 and above... Compose Compatibility androidx.navigation:navigation-compose:2.4.0-alpha01 is only compatible with Compose version 1.0.0-beta07 and above.
0

Updating Compose to beta08 and Kotlin to 1.5.10 solved the problem for me!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.