dependencies{// ...// Import the Firebase BoMimplementation(platform("com.google.firebase:firebase-bom:34.1.0"))// Using KTX libraries for Authentication and Cloud Firestoreimplementation("com.google.firebase:firebase-auth-ktx")implementation("com.google.firebase:firebase-firestore-ktx")}
升级后
dependencies{// ...// Import the Firebase BoM as usual// Make sure to use Firebase BoM v32.5.0 or higherimplementation(platform("com.google.firebase:firebase-bom:34.1.0"))// No need to use the KTX libraries; everything is now in the main moduleimplementation("com.google.firebase:firebase-auth")implementation("com.google.firebase:firebase-firestore")}
如果您不使用 Firebase Android BoM
BEFORE
dependencies{// ...// Using KTX libraries for Authentication and Cloud Firestoreimplementation("com.google.firebase:firebase-auth-ktx:23.2.1")implementation("com.google.firebase:firebase-firestore-ktx:25.1.4")}
升级后
dependencies{// ...// No need to use the KTX libraries, everything is now in the main module// Make sure to use a version listed in Firebase BoM v32.5.0 or higherimplementation("com.google.firebase:firebase-auth:24.0.1")implementation("com.google.firebase:firebase-firestore:26.0.0")}
更新您的代码,将出现的所有 KTX API 替换为 com.google.firebase 包下的主模块中重新定位的 API。
[null,null,["最后更新时间 (UTC):2025-08-13。"],[],[],null,["\u003cbr /\u003e\n\nFirebase is increasing its commitment to Kotlin, and we're working to modernize\nour Android ecosystem to make Kotlin more accessible and easy-to-use with\nFirebase.\n\nTo accomplish this modernization, we're making a few changes to our\nFirebase SDKs for Android. This page describes important information about this\nchange, including:\n\n- [What's changing](#ktx-apis-to-main-whats-changing)\n- [The reason we're making this change](#ktx-apis-to-main-why-making-change)\n- [Important dates for this change](#ktx-apis-to-main-important-dates)\n- [How to migrate to use KTX APIs from the main module](#ktx-apis-to-main-how-to-migrate)\n\n\u003cbr /\u003e\n\n\n[Learn how to migrate your app](#ktx-apis-to-main-how-to-migrate)\n| In [July 2025](/support/release-notes/android#2025-07-21), we stopped releasing new versions of the KTX modules and removed the KTX libraries from the Firebase Android BoM (v34.0.0).\n\nWhat's changing?\n\nThe Kotlin extensions (KTX) APIs have been added to their respective main\nmodules. For example, all the APIs from `firebase-perf-ktx` have been added to\n`firebase-perf` under the `com.google.firebase.perf` package.\n\n**This change means that Kotlin developers can now depend on the main modules\ninstead of the KTX modules** (when using\n[Firebase BoM v32.5.0+](/support/release-notes/android#bom_v32-5-0) or\nmain module versions listed in BoM v32.5.0+).\n\nIn July 2025, we stopped releasing new versions of the KTX modules and removed\nthe KTX libraries from the Firebase Android BoM (v34.0.0).\n| **Note:** Any currently or previously released versions of the KTX modules or BoM will still function. \n| However, we recommend that you [migrate your app to use KTX APIs from the main module](#ktx-apis-to-main-how-to-migrate) to ensure that you continue to get fixes and can take advantage of changes and new features now that new versions of the KTX modules are no longer released.\n\nWhy are we making this change?\n\nFirebase is committed to a\n[Kotlin-first](https://developer.android.com/kotlin/first)\necosystem for Android developers. This packaging modernization provides the\nfollowing advantages:\n\n- **Simplified dependency management:** You now only need to depend on a single\n module, eliminating the need to switch between the main module and the Kotlin\n extensions or to depend on both.\n\n- **Enhanced Kotlin support:** All of our Firebase SDKs for Android will now\n provide better support for Kotlin. We'll include all the new Kotlin-friendly\n features directly in our main modules.\n\nImportant dates for this change We recommend that you [migrate your app to use KTX APIs from the main module](#ktx-apis-to-main-how-to-migrate) to ensure that you continue to get fixes and can take advantage of changes and new features now that the KTX modules are no longer released.\n\n**In October 2023**\n\nIn October 2023, the Kotlin extensions (KTX) APIs were added to their respective\nmain modules, which means that you can now use the KTX APIs directly from the\nmain modules when using\n[Firebase BoM v32.5.0+](/support/release-notes/android#bom_v32-5-0) or\nmain module versions listed in BoM v32.5.0+.\n\nIn parallel, the Kotlin extension (KTX) APIs *in the KTX modules* were\ndeprecated (see the\n[release notes](/support/release-notes/android#2023-10-30) describing this\nchange). During the\n[deprecated phase](/policies/changes-to-firebase/introducing-and-communicating-changes#deprecated-phase),\nthe deprecated APIs in the KTX modules will continue to function and be\nmaintained.\n\n**In July 2025**\n\nIn July 2025, we stopped releasing new versions of the KTX modules, and we\nremoved the KTX modules from the Firebase BoM (starting with\n[BoM v34.0.0](/support/release-notes/android#bom_v34-0-0)).\n\nAny previously released version of a KTX module or the BoM will continue to\nfunction, but they're now\n[end-of-maintenance](/policies/changes-to-firebase/introducing-and-communicating-changes#end-of-maintenance).\nThis means that we won't add bug fixes, backwards-compatible changes, or\nnew features to the KTX modules. Instead, all future development for Firebase on\nAndroid will only be done in the *main modules* (for both Java and Kotlin).\n\nHow to migrate to use KTX APIs from the main modules\n\nIf you use Kotlin extensions (KTX) APIs, make the following updates in your app\nto start using the APIs from the main modules instead of the KTX modules.\n\n1. Revise your Gradle dependencies to rely on the main module rather than the\n KTX module. For example, if you use the Firebase Android BoM\n *(recommended)*:\n\n **BEFORE** \n\n ```kotlin\n dependencies {\n // ...\n\n // Import the Firebase BoM\n implementation(platform(\"com.google.firebase:firebase-bom:34.1.0\"))\n\n // Using KTX libraries for Authentication and Cloud Firestore\n implementation(\"com.google.firebase:firebase-auth-ktx\")\n implementation(\"com.google.firebase:firebase-firestore-ktx\")\n }\n ```\n\n **AFTER** \n\n ```kotlin\n dependencies {\n // ...\n\n // Import the Firebase BoM as usual\n // Make sure to use /support/release-notes/android#bom_v32-5-0 or higher\n implementation(platform(\"com.google.firebase:firebase-bom:34.1.0\"))\n\n // No need to use the KTX libraries; everything is now in the main module\n implementation(\"com.google.firebase:firebase-auth\")\n implementation(\"com.google.firebase:firebase-firestore\")\n }\n ```\n\n \u003cbr /\u003e\n\n\n **If you don't use the Firebase Android BoM**\n\n \u003cbr /\u003e\n\n **BEFORE** \n\n ```kotlin\n dependencies {\n // ...\n\n // Using KTX libraries for Authentication and Cloud Firestore\n implementation(\"com.google.firebase:firebase-auth-ktx:23.2.1\")\n implementation(\"com.google.firebase:firebase-firestore-ktx:25.1.4\")\n }\n ```\n\n **AFTER** \n\n ```kotlin\n dependencies {\n // ...\n\n // No need to use the KTX libraries, everything is now in the main module\n // Make sure to use a version listed in /support/release-notes/android#bom_v32-5-0 or higher\n implementation(\"com.google.firebase:firebase-auth:24.0.1\")\n implementation(\"com.google.firebase:firebase-firestore:26.0.0\")\n }\n ```\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n2. Update your code to replace all occurrences of the KTX APIs with the\n relocated APIs in the main module under the `com.google.firebase` package.\n\n **BEFORE** \n\n ```kotlin\n import com.google.firebase.auth.ktx.auth\n import com.google.firebase.firestore.ktx.firestore\n import com.google.firebase.firestore.ktx.toObject\n import com.google.firebase.ktx.Firebase\n ```\n\n **AFTER** \n\n ```kotlin\n import com.google.firebase.auth.auth\n import com.google.firebase.firestore.firestore\n import com.google.firebase.firestore.toObject\n import com.google.firebase.Firebase\n ```"]]