saket / cascade

Nested popup menus with smooth height animations for Android
https://saket.github.io/cascade
Apache License 2.0
2.04k stars 66 forks source link

Crash after updating androidx.compose.material3:material3 #36

Closed IssaMansour closed 1 year ago

IssaMansour commented 1 year ago

Hello,

I'm having a crash after updating from androidx.compose.material3:material3:1.1.0-beta02 to androidx.compose.material3:material3:1.2.0-alpha01.

Here the stacktrace:

FATAL EXCEPTION: main
Process: com., PID: 7951
java.lang.NoSuchMethodError: No static method AnimatedContent(Ljava/lang/Object;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Alignment;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/animation/AnimatedContentKt; or its super classes (declaration of 'androidx.compose.animation.AnimatedContentKt' appears in /data/app/~~tm7XVqFdpYIrcR6EzvOK5Q==/com.-DgU4eTqRQixR6uvl0DF5YA==/base.apk)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenuContent$2.invoke(Cascade.kt:246)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenuContent$2.invoke(Cascade.kt:233)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:132)
    at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:114)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at androidx.compose.material3.SurfaceKt.Surface-T9BRK9s(Surface.kt:111)
    at me.saket.cascade.CascadeKt.CascadeDropdownMenuContent-942rkJo(Cascade.kt:229)
    at me.saket.cascade.CascadeKt.access$CascadeDropdownMenuContent-942rkJo(Cascade.kt:1)
    at me.saket.cascade.CascadeKt$PopupContent$1.invoke(Cascade.kt:205)
    at me.saket.cascade.CascadeKt$PopupContent$1.invoke(Cascade.kt:204)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at me.saket.cascade.internal.AnimateEntryExitKt.AnimateEntryExit-hGBTI10(AnimateEntryExit.kt:147)
    at me.saket.cascade.CascadeKt.PopupContent-aC-nel8(Cascade.kt:198)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenu$2$2.invoke(Cascade.kt:169)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenu$2$2.invoke(Cascade.kt:168)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at me.saket.cascade.internal.PositionPopupContentKt.PositionPopupContent(PositionPopupContent.kt:70)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenu$2.invoke(Cascade.kt:160)
    at me.saket.cascade.CascadeKt$CascadeDropdownMenu$2.invoke(Cascade.kt:159)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.ui.window.AndroidPopup_androidKt$Popup$popupLayout$1$1$1$3.invoke(AndroidPopup.android.kt:257)
    at androidx.compose.ui.window.AndroidPopup_androidKt$Popup$popupLayout$1$1$1$3.invoke(AndroidPopup.android.kt:256)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.ui.window.AndroidPopup_androidKt$Popup$popupLayout$1$1$1.invoke(AndroidPopup.android.kt:844)
    at androidx.compose.ui.window.AndroidPopup_androidKt$Popup$popupLayout$1$1$1.invoke(AndroidPopup.android.kt:245)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.ui.window.PopupLayout.Content(AndroidPopup.android.kt:465)
    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:190)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:119)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:118)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:110)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:158)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:157)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:157)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:142)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
    at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
    at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3342)
    at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3274)
    at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:588)
    at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1004)
    at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:4005)
    at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:4005)
    at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:4005)
    at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:520)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
    at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1121)
    at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:133)
    at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:183)
    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
    at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
    at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1196)
    at android.view.View.dispatchAttachedToWindow(View.java:20812)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2675)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2179)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8798)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
    at android.view.Choreographer.doCallbacks(Choreographer.java:845)
    at android.view.Choreographer.doFrame(Choreographer.java:780)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7870)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Any idea how to fix it? I want to keep this upgraded version of material3 as it fixed other issues.

Thanks!

kasem-sm commented 1 year ago

The issue is transitionSpec param from AnimatedContent had AnimatedContentScope as it's receiver in previous compose versions but in the latest alpha version (1.5.0-alpha01+) the lambda receiver is AnimatedContentTransitionScope. @saket should I create a PR?

saket commented 1 year ago

Yes please! It'll break compatibility with older versions of compose but I guess I have no choice. AnimatedContent() was marked as experimental afterall.

kasem-sm commented 1 year ago

In 1.5.0-alpha, AnimatedContent is not marked as Experimental anymore.

IssaMansour commented 1 year ago

It is exactly as you said! I also did the fix yesterday and added this lib manually and it works well.

Didn't do a PR cause I did a quick and dirty test.

Thanks guys! When do you think it will be available? cc. @saket

The issue is transitionSpec param from AnimatedContent had AnimatedContentScope as it's receiver in previous compose versions but in the latest alpha version (1.5.0-alpha01+) the lambda receiver is AnimatedContentTransitionScope. @saket should I create a PR?

saket commented 1 year ago

Alright I just published 2.0.0 by promoting 2.0.0-rc02 to stable. We can now make breaking changes in the next version by updating compose ui to 1.5.0-alpha01.

saket commented 1 year ago

Fwiw you can quickly unblock yourself by switching to @kasem-sm's fork by using jitpack:

https://jitpack.io/#kasem-sm/cascade/99d9d12e42

saket commented 1 year ago

Released as part of https://github.com/saket/cascade/releases/tag/2.1.0. Thanks everyone!

saket commented 1 year ago

FWIW I just published a new snapshot that uses compose ui 1.5.0-beta02

implementation "me.saket.cascade:cascade-compose:2.2.0-SNAPSHOT"
saket commented 1 year ago

Scratch that, v2.2.0 is out: https://github.com/saket/cascade/releases/tag/2.2.0

kasem-sm commented 1 year ago

Scratch that, v2.2.0 is out: https://github.com/saket/cascade/releases/tag/2.2.0

Can confirm. The crash is now fixed