无法解析配置 ':app:debugRuntimeClasspath' 的所有文件。> 找不到 androidx.compose.material3:material3:1.2.0。需要者:项目 :app > > 找不到满足版本约束 '1.2.0' 的 'androidx.compose.material3:material3' 版本
Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Could not find androidx.compose.material3:material3:1.2.0. Required by: project :app > > Cannot find a version of 'androidx.compose.material3:material3' that satisfies the version constraint '1.2.0'
ID: android/gradle-version-catalog-not-found
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Android Gradle Plugin 8.0 - 8.2 | active | — | — | — |
| Gradle 8.0 - 8.5 | active | — | — | — |
| Compose BOM 2023.10.01 - 2024.02.00 | active | — | — | — |
根因分析
版本目录或依赖声明引用了配置的仓库中不存在的库版本,或仓库(如 Maven Central、Google)不可达或缺少该工件。
English
Version catalog or dependency declaration references a library version that does not exist in the configured repositories, or the repository (e.g., Maven Central, Google) is not reachable or missing the artifact.
官方文档
https://developer.android.com/build/dependencies#version-catalog解决方案
-
Update the version catalog file (libs.versions.toml) to use a valid version from the Google Maven repository: 'material3 = "1.2.1"' and then run 'gradlew clean build'.
-
Add the Google Maven repository explicitly in settings.gradle or build.gradle: 'maven { url "https://maven.google.com" }' and ensure it's before other repositories.
无效尝试
常见但无效的做法:
-
50% 失败
If the repository is already present but the artifact doesn't exist, adding it again won't help; the version must be verified.
-
50% 失败
Older versions may not be compatible with the current Compose or AndroidX libraries, causing other build failures.