Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am getting crash every time with the datepicker #112

Closed
Shashank02051997 opened this issue Oct 5, 2021 · 10 comments
Closed

I am getting crash every time with the datepicker #112

Shashank02051997 opened this issue Oct 5, 2021 · 10 comments

Comments

@Shashank02051997
Copy link

Shashank02051997 commented Oct 5, 2021

No static method AnimatedVisibility(ZLandroidx/compose/ui/Modifier;Landroidx/compose/animation/EnterTransition;Landroidx/compose/animation/ExitTransition;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/animation/AnimatedVisibilityKt; or its super classes (declaration of 'androidx.compose.animation.AnimatedVisibilityKt' appears in /data/app/com.mirus.orpheuspatientapp.androidApp-uddfwQzqociDqoGlch52bg==/base.apk)
        at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt$DatePickerImpl$1$1.invoke(DatePicker.kt:129)
        at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt$DatePickerImpl$1$1.invoke(DatePicker.kt:117)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at com.google.accompanist.pager.Pager.Pager-_-WMjBM(Pager.kt:309)
@skolson
Copy link
Contributor

skolson commented Oct 5, 2021

Seeing the same using compose 1.1.0-alph04> I'm guessing this is because I'm missing a compose animation dependency. Looking to see if that is true...

@skolson
Copy link
Contributor

skolson commented Oct 5, 2021

Sure enuff, default animation library in use was 1.0.x even though I was using 1.1.0-alpha04. During research I saw that alpha05 is out, which requires kotlin 1.5.31. So changed to both of those and added this to the main kotlin sourceset in the android module:

runtimeOnly(androidx.compose.animation:animation:1.1.0-alpha05)

This changed the exception when using DatePicker to this:

java.lang.NoSuchMethodError: No static method slideInVertically$default...

So now I'm looking into where that comes from...

@skolson
Copy link
Contributor

skolson commented Oct 5, 2021

Something is still pulling in 1.0.1 of the animations. This is the only compose library doing this, all the others are just using 1.1.0-alpha05 as desired. Here's the relevant snip from the External Libraries display for my project:
image

None of my code is explicitly using animations, so this animation 1.0.1 dependency is either coming from date picker or from something within compose. I'm going to mess with dependencies in gradle to see if I can stop this and force it to only use 1.1.0-alpha05. WIll post again if I find a fix.

@skolson
Copy link
Contributor

skolson commented Oct 5, 2021

The 1.0.1 stuff is fixed by changing the gradle entry for animation to "implementation".

implementation(androidx.compose.animation:animation:1.1.0-alpha05)

But the same error remains when attempting to use date picker even after the 1.0.1 stuff is gone:

    java.lang.NoSuchMethodError: No static method slideInVertically$default(Lkotlin/jvm/functions/Function1;Landroidx/compose/animation/core/FiniteAnimationSpec;ILjava/lang/Object;)Landroidx/compose/animation/EnterTransition; in class Landroidx/compose/animation/EnterExitTransitionKt; or its super classes (declaration of 'androidx.compose.animation.EnterExitTransitionKt' appears in /data/app/~~FUPuM9ytG9LZPiGG-y05eg==/com.oldguy.monay-jCFG478Y2cpB30Eod5buJw==/base.apk)
        at com.vanpra.composematerialdialogs.datetime.date.DatePickerKt$DatePickerImpl$1$1.invoke(DatePicker.kt:134)
        ...

Still looking...

@skolson
Copy link
Contributor

skolson commented Oct 5, 2021

Ok, here's the problem - the method signatures for both slideInVertically and slideOutVertically have changed. Here's slideInVertically now:

fun slideInVertically(
    animationSpec: FiniteAnimationSpec<IntOffset> =
        spring(
            stiffness = Spring.StiffnessMediumLow,
            visibilityThreshold = IntOffset.VisibilityThreshold
        ),
    initialOffsetY: (fullHeight: Int) -> Int = { -it / 2 },
): EnterTransition =

Line 134 in date picker is this:

enter = slideInVertically({ -it }),

and needs to be (at least) this:

enter = slideInVertically(initialOffsetY = { -it }),

Assuming of course the default animationSpec (now the first argument) is ok.

The good news is they've removed to Experimental annotation from both these functions, now they are marked as @stable. Si hopefully they won't change again.

So I'm stuck for now. If I can get time, may attempt a pull request later, but I have not looked at the internals of the project much so don't know how much other stuff might pop when going to kotlin 1.5.31 and 1.1.0-alpha05 of compose...

@PranavMaganti
Copy link
Owner

Thanks for all the investigation and information. I'll try and have a look at upgrading to kotlin 1.5.31 and 1.1.0-alpha05 some time later today but if I don't feel free to submit a PR.

@skolson
Copy link
Contributor

skolson commented Oct 7, 2021

I started working towards a PR, but am having trouble with the gradle dependencies. Somehow it is pulling in 1.0.0 of animation and animation-core along with the current ones. Until I get that stopped, the build works when it shouldn't...

Update: I found this problem, had to add explicit dependencies in a couple places for both animation and foundation layout libraries to get them to be the same version as compose. That stopped whatever was pulling the old libraries and allowing the build to work when it shouldn't. Tomorrow I should be able to do a PR...

@skolson
Copy link
Contributor

skolson commented Oct 7, 2021

Vanpra, I see you did a pull request for 0.6.1 so I won't do mine. But I think it would be good to add these changes to yours. This makes explicit the dependency on animation and ensures an old one won't be picked up by default:

Dependencies.kt add

            const val animation = "androidx.compose.animation:animation:$version"
            const val foundationLayout = "androidx.compose.foundation:foundation-layout:$version"

CommonModulePlugin.kt add dependencies

            implementation(Dependencies.AndroidX.Compose.animation)
            implementation(Dependencies.AndroidX.Compose.foundationLayout)

app\build.gradle.kts add dependencies

    implementation(Dependencies.AndroidX.Compose.animation)
    implementation(Dependencies.AndroidX.Compose.foundationLayout)

Without these, in project view, check external dependencies and see if there are entries for two different versions of the compose animations libraries. The old refs allow the build to succeed even without changing the usage of slideInVertically and slideOutVertically

@PranavMaganti
Copy link
Owner

Thanks for letting me know. I've added the above lines to the PR.

@PranavMaganti
Copy link
Owner

This should be fixed in the 0.6.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants