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

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

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:

  1. import androidx.compose.animation.AnimatedContent
  2. import androidx.compose.runtime.*
  3. //...
  4. var progress by remember { mutableStateOf(1) }
  5. AnimatedContent(
  6. targetState = progress,
  7. modifier = Modifier.fillMaxWidth(),
  8. transitionSpec = {
  9. slideInOutLeft()
  10. }
  11. ) {
  12. // my other composables
  13. }

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

  1. import androidx.compose.animation.AnimatedContentTransitionScope
  2. import androidx.compose.animation.ContentTransform
  3. import androidx.compose.animation.core.EaseInOut
  4. import androidx.compose.animation.core.tween
  5. import androidx.compose.animation.with
  6. inline fun <reified T> AnimatedContentTransitionScope<T>.slideInOutLeft(): ContentTransform
  7. = slideIntoContainer(
  8. animationSpec = tween(300, easing = EaseInOut),
  9. towards = AnimatedContentTransitionScope.SlideDirection.Left
  10. ).with(
  11. slideOutOfContainer(
  12. animationSpec = tween(300, easing = EaseInOut),
  13. towards = AnimatedContentTransitionScope.SlideDirection.Left
  14. )
  15. )

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:

  1. 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

  1. import androidx.compose.animation.AnimatedContent
  2. import androidx.compose.runtime.*
  3. //...
  4. var progress by remember { mutableStateOf(1) }
  5. AnimatedContent(
  6. targetState = progress,
  7. modifier = Modifier.fillMaxWidth(),
  8. transitionSpec = {
  9. slideInOutLeft()
  10. }
  11. ) {
  12. // my other composables
  13. }

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

  1. import androidx.compose.animation.AnimatedContentTransitionScope
  2. import androidx.compose.animation.ContentTransform
  3. import androidx.compose.animation.core.EaseInOut
  4. import androidx.compose.animation.core.tween
  5. import androidx.compose.animation.with
  6. inline fun &lt;reified T&gt; AnimatedContentTransitionScope&lt;T&gt;.slideInOutLeft(): ContentTransform
  7. = slideIntoContainer(
  8. animationSpec = tween(300, easing = EaseInOut),
  9. towards = AnimatedContentTransitionScope.SlideDirection.Left
  10. ).with(
  11. slideOutOfContainer(
  12. animationSpec = tween(300, easing = EaseInOut),
  13. towards = AnimatedContentTransitionScope.SlideDirection.Left
  14. )
  15. )

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

  1. 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

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

update accompanist navigation animation dependencies to 0.31.5-beta

  1. 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:

确定