程式庫版本
自 15.0.0 版起,Google Play 服務程式庫會個別維護,讓各程式庫的開發團隊能獨立且更快速地提供修正和增強功能。您可以追蹤 Google Play 服務和 Firebase 的最新版本。
嚴格版本比對
某個程式庫的版本可能與另一個程式庫的特定版本不相容。為協助處理這種情況,有幾個 Gradle 外掛程式會提供這些版本不相符的相關指引。這些外掛程式中的邏輯與 failOnVersionConflict()
規則中的邏輯相似,適用於與 Google Play 服務和 Firebase 依附元件相關聯的 ResolutionStrategy
。
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'
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-04-15 (世界標準時間)。
[null,null,["上次更新時間:2025-04-15 (世界標準時間)。"],[[["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"]]