JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
14.85k stars 1.08k forks source link

java.lang.NoSuchFieldError: No static field hide_in_inspector_tag of type I in class Landroidx/compose/ui/R$id; or its superclasses (declaration of 'androidx.compose.ui.R$id' appears in #4711

Closed razaghimahdi closed 2 weeks ago

razaghimahdi commented 3 weeks ago

org.jetbrains.androidx.navigation:navigation-compose causes crash, and it says: java.lang.NoSuchFieldError: No static field hide_in_inspector_tag of type I in class Landroidx/compose/ui/R$id; or its superclasses (declaration of 'androidx.compose.ui.R$id' appears in androidx.compose.material.ripple.RippleContainer.(RippleContainer.android.kt:70) at androidx.compose.material.ripple.AndroidRippleIndicationInstance.getOrCreateRippleContainer(Ripple.android.kt:255) at androidx.compose.material.ripple.AndroidRippleIndicationInstance.addRipple(Ripple.android.kt:198) at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:138) at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:136)

compose-navigation-ver = "2.8.0-alpha02" compose = "1.6.10-beta01"

I get this crash in every version, how to fix that?

Update: sample : https://github.com/razaghimahdi/Shopping-By-KMP/tree/compose-navigation

Zenturas commented 3 weeks ago

i get this error too only if running android build works, error get thrown if clicking on button if i remove navigation lib build and click works normally

java.lang.NoSuchFieldError: No static field hide_in_inspector_tag of type I in class Landroidx/compose/ui/R$id; or its superclasses (declaration of 'androidx.compose.ui.R$id' appears in /data/app/~~FDW5lZdq4wdPpHjDGB8Mbw==/de.composeTests-QLFqbqvVGdeF4h1Equ0APA==/base.apk!classes2.dex)
                                                                                                        at androidx.compose.material.ripple.RippleContainer.<init>(RippleContainer.android.kt:70)
                                                                                                        at androidx.compose.material.ripple.AndroidRippleIndicationInstance.getOrCreateRippleContainer(Ripple.android.kt:255)
                                                                                                        at androidx.compose.material.ripple.AndroidRippleIndicationInstance.addRipple(Ripple.android.kt:198)
                                                                                                        at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:138)
                                                                                                        at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:136)
                                                                                                        at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:392)
                                                                                                        at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8762)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@9cb18e6, androidx.compose.runtime.BroadcastFrameClock@4f3de27, StandaloneCoroutine{Cancelling}@2afa8d4, AndroidUiDispatcher@233aa7d]

jetbrains-navigation-compose-version = "2.8.0-beta01" jetbrains-lifecycle-compose-version = "2.8.0-alpha01" jetbrains-compose-multiplatform-version = "1.6.10-beta02"

razaghimahdi commented 3 weeks ago

sample that I'm trying to use: https://github.com/razaghimahdi/Shopping-By-KMP/tree/compose-navigation

razaghimahdi commented 3 weeks ago

i get this error too only if running android build works, error get thrown if clicking on button if i remove navigation lib build and click works normally

java.lang.NoSuchFieldError: No static field hide_in_inspector_tag of type I in class Landroidx/compose/ui/R$id; or its superclasses (declaration of 'androidx.compose.ui.R$id' appears in /data/app/~~FDW5lZdq4wdPpHjDGB8Mbw==/de.composeTests-QLFqbqvVGdeF4h1Equ0APA==/base.apk!classes2.dex)
                                                                                                      at androidx.compose.material.ripple.RippleContainer.<init>(RippleContainer.android.kt:70)
                                                                                                      at androidx.compose.material.ripple.AndroidRippleIndicationInstance.getOrCreateRippleContainer(Ripple.android.kt:255)
                                                                                                      at androidx.compose.material.ripple.AndroidRippleIndicationInstance.addRipple(Ripple.android.kt:198)
                                                                                                      at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:138)
                                                                                                      at androidx.compose.material.ripple.Ripple$rememberUpdatedInstance$1$1.emit(Ripple.kt:136)
                                                                                                      at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:392)
                                                                                                      at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
                                                                                                      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                      at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                      at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                      at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                      at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                      at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                      at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                      at android.os.Looper.loop(Looper.java:313)
                                                                                                      at android.app.ActivityThread.main(ActivityThread.java:8762)
                                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
                                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
                                                                                                      Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@9cb18e6, androidx.compose.runtime.BroadcastFrameClock@4f3de27, StandaloneCoroutine{Cancelling}@2afa8d4, AndroidUiDispatcher@233aa7d]

jetbrains-navigation-compose-version = "2.8.0-beta01" jetbrains-lifecycle-compose-version = "2.8.0-alpha01" jetbrains-compose-multiplatform-version = "1.6.10-beta02"

thanks for the detail

AlexBurdu commented 2 weeks ago

+1 that the navigation library clashes somehow with the material ripple library version. My guess is that in brings in a broken ripple dependency that was probably fixed in newer versions. (https://stackoverflow.com/questions/78248205/android-compose-animations-crashing-in-release-builds)

AlexBurdu commented 2 weeks ago

Temporary mitigation:

configurations.all {
    resolutionStrategy {
        force("androidx.compose.material:material-ripple:1.7.0-alpha05") }
}
razaghimahdi commented 2 weeks ago

Temporary mitigation:

  • Add the following in your android app module build.gradle.kts file (root level block)
configurations.all {
    resolutionStrategy {
        force("androidx.compose.material:material-ripple:1.7.0-alpha05") }
}

works fine for now! thanks for ur help man

AlexBurdu commented 2 weeks ago

I think the bug is still valid and worth keeping open.

razaghimahdi commented 2 weeks ago

I think the bug is still valid and worth keeping open.

Actually u r right👍

MatkovIvan commented 2 weeks ago

I guess it's because version conflict. See my explanation here - https://github.com/JetBrains/compose-multiplatform/issues/4677#issuecomment-2070731977

Please try to update to the latest compose - 1.6.10-beta03 navigation - 2.7.0-alpha03 (note 2.7, not 2.8)

MatkovIvan commented 2 weeks ago

Closing as duplicate of #4677

The cause was that Google's jetpack navigation 2.8.* (we're using original binary on Android) introduced requirement of Compose 1.7 that is not adopted for multiplatform yet. I believe that it was fixed https://github.com/JetBrains/compose-multiplatform-core/pull/1315 - we'll be on 2.7 version until Compose Multiplatform 1.7