AnimatedContentTransitionScope 在运行 compileReleaseKotlin gradle 任务时无法解析。

huangapple go评论67阅读模式
英文:

AnimatedContentTransitionScope is unresolved when i run the compileReleaseKotlin gradle task

问题

I'm building an Android application using Jetpack Compose 1.5.0-alpha02 and utilizing the animated content composable as below:

import androidx.compose.animation.AnimatedContent
import androidx.compose.runtime.*

//...

var progress by remember { mutableStateOf(1) }

AnimatedContent(
    targetState = progress,
    modifier = Modifier.fillMaxWidth(),
    transitionSpec = {
        slideInOutLeft()
    }
) {
    // my other composables
}

I extracted the slideInOut() function to a file called "transitions" so that I can reuse it in multiple places, but this is its implementation:

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.ContentTransform
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.tween
import androidx.compose.animation.with

inline fun <reified T> AnimatedContentTransitionScope<T>.slideInOutLeft(): ContentTransform
    = slideIntoContainer(
        animationSpec = tween(300, easing = EaseInOut),
        towards = AnimatedContentTransitionScope.SlideDirection.Left
    ).with(
        slideOutOfContainer(
            animationSpec = tween(300, easing = EaseInOut),
            towards = AnimatedContentTransitionScope.SlideDirection.Left
        )
    )

When I run and build the app on an emulator or physical device, I get no errors. However, when I try to push it to GitHub, the gradle compileReleaseKotlin Gradle task fails, and this is the error I'm getting:

Unresolved reference: AnimatedContentTransitionScope

I've tried upgrading dependencies, downgrading them, reading the documentation, searching the internet, but I couldn't find a solution. Any help would be highly appreciated as I don't know what's wrong.

英文:

Im building an android application using Jetpack Compose 1.5.0-alpha02 and utilizing the animated content composable as below


import androidx.compose.animation.AnimatedContent
import androidx.compose.runtime.*

//...

var progress by remember { mutableStateOf(1) }

AnimatedContent(
    targetState = progress,
    modifier = Modifier.fillMaxWidth(),
    transitionSpec = {
        slideInOutLeft()
    }
) {
// my other composables
}

I extracted the slideInOut() function to a file called transitions so that i can reuse it in multiple places but this is its implementations


import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.ContentTransform
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.tween
import androidx.compose.animation.with


inline fun &lt;reified T&gt; AnimatedContentTransitionScope&lt;T&gt;.slideInOutLeft(): ContentTransform
    = slideIntoContainer(
        animationSpec = tween(300, easing = EaseInOut),
        towards = AnimatedContentTransitionScope.SlideDirection.Left
    ).with(
        slideOutOfContainer(
            animationSpec = tween(300, easing = EaseInOut),
            towards = AnimatedContentTransitionScope.SlideDirection.Left

        )
    )

When i run and build the app on an emulator or physical device i get no errors but when i try to push it to github, the gradle compileReleaseKotlin gradle task was failing. and this is the error I'm getting

Unresolved reference: AnimatedContentTransitionScope

Ive tried upgrading dependencies, downgrading them reading the documentation searching the internet using gpt4 but no results. Please any help will be highly appreciated as i dont know whats wrong

答案1

得分: 1

更新伴奏导航动画依赖项至 0.31.5-beta

implementation "com.google.accompanist:accompanist-navigation-animation:0.31.5-beta"
英文:

update accompanist navigation animation dependencies to 0.31.5-beta

implementation &quot;com.google.accompanist:accompanist-navigation-animation:0.31.5-beta&quot;

huangapple
  • 本文由 发表于 2023年4月13日 19:06:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004695.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定