android-jetpack-composewear-os

Wear OS TimeText() Exception


I've just tried to build and run the default Wear OS project for an app with tile and complication, but I get this run-time error in the simulator:

Process: au.gondwanasoftware.ontrack, PID: 9869
java.lang.NoSuchMethodError: No static method mutableStateOf(J)Landroidx/compose/runtime/MutableLongState; in class Landroidx/compose/runtime/SnapshotLongStateKt; or its super classes (declaration of 'androidx.compose.runtime.SnapshotLongStateKt' appears in /data/app/~~q11wAqlBg8mZ6aPx5tjsyw==/au.gondwanasoftware.ontrack-s9r1ombsSKACiWkkVk3gnw==/base.apk)
    at androidx.wear.compose.material.DefaultTimeSourceKt.currentTime(DefaultTimeSource.kt:53)
    at androidx.wear.compose.material.DefaultTimeSource.getCurrentTime(DefaultTimeSource.kt:42)
    at androidx.wear.compose.material.TimeTextKt.TimeText(TimeText.kt:101)
    ...

If I comment out TimeText(), it runs.

targetSdk is 34.

Something is probably wrong with my configuration. I realise that this probably isn't enough info to diagnose, but I don't know what more is needed. Please let me know!


Solution

  • In build.gradle.kts, update the version of androidx.wear.compose libraries to 1.2.1:

        implementation("androidx.wear.compose:compose-material:1.2.1")
        implementation("androidx.wear.compose:compose-foundation:1.2.1")
    

    EDIT: As per reply in the bug report, this fix should be available in Android Studio Iguana.