库版本
从 15.0.0 版开始,Google Play 服务库将单独维护,这样每个库的开发团队就可以独立且更快地发布修复程序和增强功能。您可以跟踪 Google Play 服务和 Firebase 的最新版本。
严格版本匹配
某个库的某个版本可能与另一个库的特定版本不兼容。为了帮助处理这种情况,有几个 Gradle 插件提供了有关这些版本不匹配问题的指导。这些插件中的逻辑与与 Google Play 服务和 Firebase 依赖项关联的 ResolutionStrategy
的 failOnVersionConflict()
规则中的逻辑类似。
Google 服务插件
Google 服务 Gradle 插件会检查是否有兼容的 Google Play 服务和 Firebase 库版本。
独立版本匹配器插件
如果您不使用 Google 服务插件,但仍希望对依赖项进行严格的版本检查,可以应用 [strict-version-matcher-plugin
]。您可以在 GitHub 上查看此插件的代码。
以下代码段展示了如何添加 Gradle 插件:
build.gradle.kts
plugin {
id("com.google.android.gms.strict-version-matcher-plugin")
}
build.gradle
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'
如需使用此插件,您还需要将从 Google 的 Maven 制品库中获取的以下内容添加到 buildscript 类路径中:
build.gradle.kts
classpath("com.google.android.gms:strict-version-matcher-plugin:1.2.4")
build.gradle
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.4'
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-07。
[null,null,["最后更新时间 (UTC):2025-03-07。"],[[["Google Play services libraries are now individually maintained, allowing for faster and more frequent updates to individual components."],["Strict version matching is crucial as library versions might be incompatible, and the Google Services Gradle plugin and the standalone strict-version-matcher-plugin help manage these dependencies."],["The `strict-version-matcher-plugin` offers a way to ensure version compatibility for Google Play services and Firebase dependencies, even without using the Google Services plugin."],["To utilize the standalone plugin, you need to add it to your buildscript classpath and apply it in your Gradle file using the provided code snippets."]]],["Google Play services libraries are individually maintained, enabling faster updates. To manage potential version incompatibilities between libraries, Gradle plugins provide guidance. The Google Services Gradle plugin checks for compatible versions of Google Play services and Firebase libraries. Alternatively, the `strict-version-matcher-plugin` offers dependency version checking without the Google Services plugin. To use it you must add the plugin and the `strict-version-matcher-plugin` classpath to your build script.\n"]]