You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Jetpack Compose BOM至2024.01.00后CircularProgressIndicator报错求助

Jetpack Compose BOM升级至2024.01.00后CircularProgressIndicator出现NoSuchMethodError错误

近期将项目中的Jetpack Compose BOM版本升级至最新的2024.01.00后,CircularProgressIndicator组件抛出了NoSuchMethodError错误,具体堆栈信息如下:

java.lang.NoSuchMethodError: No virtual method at(Ljava/lang/Object;I)Landroidx/compose/animation/core/KeyframesSpec$KeyframeEntity; in class Landroidx/compose/animation/core/KeyframesSpec$KeyframesSpecConfig; or its super classes (declaration of 'androidx.compose.animation.core.KeyframesSpec$KeyframesSpecConfig' appears in /data/app/~~Sbx7baz2GwMCcVZ6x7z-CA==/com.ai.aso.wallpaper-PqJGZgl7MXHWAf_XL7CGuA==/base.apk)
                                        at androidx.compose.material3.ProgressIndicatorKt$CircularProgressIndicator$endAngle$1.invoke(ProgressIndicator.kt:371)
                                        at androidx.compose.material3.ProgressIndicatorKt$CircularProgressIndicator$endAngle$1.invoke(ProgressIndicator.kt:369)
                                        at androidx.compose.animation.core.AnimationSpecKt.keyframes(AnimationSpec.kt:649)
                                        at androidx.compose.material3.ProgressIndicatorKt.CircularProgressIndicator-LxG7B9w(ProgressIndicator.kt:369)
                                        at com.ai.aso.wallpaper.presentation.screens.browse.BrowseScreenKt.BrowseScreen(BrowseScreen.kt:159)
                                        at com.ai.aso.wallpaper.presentation.screens.home.HomeScreenKt$HomeScreen$3$3$1$1.invoke(HomeScreen.kt:161)
                                        at com.ai.aso.wallpaper.presentation.screens.home.HomeScreenKt$HomeScreen$3$3$1$1.invoke(HomeScreen.kt:158)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:139)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                        at androidx.compose.foundation.pager.PagerLazyLayoutItemProvider$Item$1.invoke(LazyLayoutPager.kt:199)
                                        at androidx.compose.foundation.pager.PagerLazyLayoutItemProvider$Item$1.invoke(LazyLayoutPager.kt:197)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:248)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutPinnableItemKt.LazyLayoutPinnableItem(LazyLayoutPinnableItem.kt:58)
                                        at androidx.compose.foundation.pager.PagerLazyLayoutItemProvider.Item(LazyLayoutPager.kt:197)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt$SkippableItem$1.invoke(LazyLayoutItemContentFactory.kt:135)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt$SkippableItem$1.invoke(LazyLayoutItemContentFactory.kt:134)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                        at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:248)
                                        at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
                                        at androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.SaveableStateProvider(LazySaveableStateHolder.kt:85)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt.SkippableItem-JVlU9Rs(LazyLayoutItemContentFactory.kt:134)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt.access$SkippableItem-JVlU9Rs(LazyLayoutItemContentFactory.kt:1)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:101)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:91)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:989)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$3$1$1.invoke(SubcomposeLayout.kt:476)
2024-01-26 16:05:55.828  8297-8297  AndroidRuntime          com.ai.aso.wallpaper                 E      at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
                                        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                        at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:90)
                                        at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3302)
                                        at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3235)
                                        at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:723)
                                        at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1071)
                                        at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3599)
                                        at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3599)
                                        at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:631)
                                        at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:617)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:499)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:471)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:462)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:446)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:871)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutMeasureScopeImpl.measure-0kLqBqw(LazyLayoutMeasureScope.kt:125)
                                        at androidx.compose.foundation.pager.PagerMeasureKt.getAndMeasure-SGf7dI0(PagerMeasure.kt:522)
                                        at androidx.compose.foundation.pager.PagerMeasureKt.measurePager-_JDW0YA(PagerMeasure.kt:203)
                                        at androidx.compose.foundation.pager.PagerMeasurePolicyKt$rememberPagerMeasurePolicy$1$1.invoke-0kLqBqw(PagerMeasurePolicy.kt:159)
                                        at androidx.compose.foundation.pager.PagerMeasurePolicyKt$rememberPagerMeasurePolicy$1$1.invoke(PagerMeasurePolicy.kt:69)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke-0kLqBqw(LazyLayout.kt:107)
                                        at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke(LazyLayout.kt:100)
                                        at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:708)
                                        at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:126)
                                        at androidx.compose.foundation.AndroidOverscroll_androidKt$StretchOverscrollNonClippingLayer$2.invoke-3p2s80s(AndroidOverscroll.android.kt:584)
                                        at androidx.compose.foundation.AndroidOverscroll_androidKt$StretchOverscrollNonClippingLayer$2.invoke(AndroidOverscroll.android.kt:583)

问题原因

该错误源于依赖版本不兼容:Compose BOM 2024.01.00对应的Material3库使用了Compose Animation Core中新增的KeyframesSpec.KeyframesSpecConfig.at(Object, Int)方法,但项目中可能存在旧版Animation Core依赖,或依赖解析时拉取了不匹配的版本,导致方法找不到。

解决方法

  • 统一Compose依赖版本:确保所有Compose相关依赖都通过BOM引入,不单独指定版本,让BOM自动管理版本一致性:
    dependencies {
        // 引入Compose BOM
        implementation platform('androidx.compose:compose-bom:2024.01.00')
        // 其他Compose依赖无需指定版本
        implementation 'androidx.compose.material3:material3'
        implementation 'androidx.compose.animation:animation-core'
        implementation 'androidx.compose.ui:ui'
        // 其他Compose依赖...
    }
    
  • 清理缓存并重建项目:执行Gradle命令清除旧缓存,重新构建:
    ./gradlew clean build
    
  • 排查依赖冲突:使用Gradle依赖报告查看是否有旧版animation-core被引入:
    ./gradlew dependencies
    
    若发现冲突,可在对应依赖中排除旧版本,或强制使用BOM指定的版本。

内容的提问来源于stack exchange,提问作者Chirag Thummar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 18:40:56