به استفاده از برنامه های افزودنی Kotlin (KTX) در ماژول های اصلی مهاجرت کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Firebase تعهد خود را به Kotlin افزایش میدهد و ما در تلاش هستیم تا اکوسیستم Android خود را مدرنسازی کنیم تا Kotlin را با Firebase در دسترستر و آسانتر کنیم.
برای انجام این مدرنسازی، چند تغییر در Firebase SDK خود برای Android ایجاد میکنیم. این صفحه اطلاعات مهمی را در مورد این تغییر شرح می دهد، از جمله:
APIهای افزونه های Kotlin (KTX) به ماژول های اصلی مربوطه اضافه شده اند. برای مثال، همه APIهای firebase-perf-ktx به firebase-perf در بسته com.google.firebase.perf اضافه شدهاند.
این تغییر به این معنی است که توسعه دهندگان Kotlin اکنون می توانند به جای ماژول های KTX (هنگام استفاده از Firebase BoM v32.5.0+ یا نسخه های ماژول اصلی فهرست شده در BoM v32.5.0+) به ماژول های اصلی وابسته باشند.
در جولای 2025، انتشار نسخههای جدید ماژولهای KTX را متوقف کردیم و کتابخانههای KTX را از Firebase Android BoM (v34.0.0) حذف کردیم.
چرا این تغییر را ایجاد می کنیم؟
Firebase متعهد به اولین اکوسیستم Kotlin برای توسعه دهندگان اندروید است. این نوسازی بسته بندی مزایای زیر را ارائه می دهد:
مدیریت وابستگی ساده: اکنون فقط باید به یک ماژول تکیه کنید و نیازی به جابجایی بین ماژول اصلی و پسوندهای Kotlin یا وابستگی به هر دو را از بین ببرید.
پشتیبانی پیشرفته Kotlin: همه Firebase SDK های ما برای Android اکنون پشتیبانی بهتری از Kotlin ارائه می دهند. ما تمام ویژگی های جدید سازگار با Kotlin را مستقیماً در ماژول های اصلی خود قرار خواهیم داد.
تاریخ های مهم برای این تغییر
در اکتبر 2023
در اکتبر 2023، APIهای افزونه های Kotlin (KTX) به ماژول های اصلی مربوطه اضافه شدند، به این معنی که اکنون می توانید در هنگام استفاده Firebase BoM v32.5.0+ یا نسخه های ماژول اصلی فهرست شده در BoM v32.5.0+، از API های KTX مستقیماً از ماژول های اصلی استفاده کنید.
به موازات آن، APIهای پسوند Kotlin (KTX) در ماژولهای KTX منسوخ شدند ( به یادداشتهای انتشار در توصیف این تغییر مراجعه کنید). در طول فاز منسوخ شده ، APIهای منسوخ در ماژول های KTX به کار خود ادامه می دهند و حفظ می شوند.
در جولای 2025
در جولای 2025، انتشار نسخههای جدید ماژولهای KTX را متوقف کردیم و ماژولهای KTX را از Firebase BoM حذف کردیم (شروع با BoM v34.0.0 ).
هر نسخهای که قبلاً از یک ماژول KTX یا BoM منتشر شده بود، به کار خود ادامه میدهد، اما اکنون در پایان تعمیر و نگهداری هستند. این بدان معناست که ما رفع اشکال، تغییرات سازگار با عقب، یا ویژگیهای جدید را به ماژولهای KTX اضافه نمیکنیم. در عوض، تمام توسعههای آینده Firebase در اندروید فقط در ماژولهای اصلی (هم برای جاوا و هم برای Kotlin) انجام میشود.
نحوه مهاجرت به استفاده از API های KTX از ماژول های اصلی
اگر از APIهای افزونه های Kotlin (KTX) استفاده می کنید، به روز رسانی های زیر را در برنامه خود انجام دهید تا از ماژول های اصلی به جای ماژول های KTX، از API ها استفاده کنید.
وابستگی های Gradle خود را برای تکیه بر ماژول اصلی به جای ماژول KTX تجدید نظر کنید. به عنوان مثال، اگر از Firebase Android BoM استفاده می کنید (توصیه می شود) :
قبل از
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 استفاده نمی کنید
قبل از
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")}
کد خود را بهروزرسانی کنید تا همه رخدادهای APIهای KTX با APIهای جابجا شده در ماژول اصلی تحت بسته com.google.firebase جایگزین شوند.
تاریخ آخرین بهروزرسانی 2025-08-08 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-08 بهوقت ساعت هماهنگ جهانی."],[],[],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.2.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.2.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 ```"]]