无法添加 ProgressIndicators(应用程序崩溃)

Jul*_*ies 32 android gradle kotlin android-jetpack-compose

当我使用任何类型的进度指示器(例如)CircularProgressIndicator()LinearProgressIndicator()我的应用程序崩溃时:

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/~~rlFP4ThDS2yjsD1Xsh1cWQ==/es.jvbabi.vplanplus-6LDitHOwZpwGZt8Ywx6lFQ==/base.apk)
    at androidx.compose.material3.ProgressIndicatorKt$CircularProgressIndicator$endAngle$1.invoke(ProgressIndicator.kt:302)
    at androidx.compose.material3.ProgressIndicatorKt$CircularProgressIndicator$endAngle$1.invoke(ProgressIndicator.kt:300)
Run Code Online (Sandbox Code Playgroud)

这些是我与此问题相关的依赖项:

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.8.0")
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material3:material3")
Run Code Online (Sandbox Code Playgroud)

无论我把它们放在哪里,它们都会导致应用程序崩溃。

Jul*_*ies 28

使用此版本(已确认有效)或更新版本应该可以解决该问题。 查看 mvnrepository 上的所有版本

implementation("androidx.compose.material3:material3-android:1.2.0-alpha10")
Run Code Online (Sandbox Code Playgroud)


Ole*_*ura 12

这是一个已知问题https://issuetracker.google.com/issues/322214617 作为临时解决方案,您可以在 Gradle 文件中使用此声明

implementation("androidx.compose.material3:material3-android:1.2.0-rc01")
Run Code Online (Sandbox Code Playgroud)

代替

implementation("androidx.compose.material3:material3")
Run Code Online (Sandbox Code Playgroud)

  • 现在它已修复在“compose-bom:2024.02.00”中,因此,您可以使用: `implementation(platform("androidx.compose:compose-bom:2024.02.00"))` `implementation("androidx.compose.material3: Material3")` 它有效 (2认同)

小智 5

chage implementation("androidx.compose.material:material-icons-extended:1.6.0-alpha08")to 1.6.0-alpha07,它对我有用,也许它有一个错误1.6.0-alpha08