الانتقال إلى استخدام واجهات برمجة تطبيقات إضافات Kotlin (KTX) في الوحدات الرئيسية
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تزيد Firebase من التزامها بلغة Kotlin، ونحن نعمل على تطوير منظومتنا المتكاملة لنظام Android لتسهيل استخدام Kotlin مع Firebase.
لإجراء هذا التحديث، سنجري بعض التغييرات على حِزم تطوير البرامج (SDK) لنظام التشغيل Android في Firebase. توضّح هذه الصفحة معلومات مهمة حول هذا التغيير، بما في ذلك:
تمت إضافة واجهات برمجة تطبيقات إضافات Kotlin (KTX) إلى الوحدات الرئيسية الخاصة بها. على سبيل المثال، تمت إضافة جميع واجهات برمجة التطبيقات من firebase-perf-ktx إلى firebase-perf ضمن حزمة com.google.firebase.perf.
يعني هذا التغيير أنّه أصبح بإمكان مطوّري Kotlin الاعتماد على الوحدات الرئيسية
بدلاً من وحدات KTX (عند استخدام
الإصدار 32.5.0 أو الإصدارات الأحدث من Firebase BoM أو
إصدارات الوحدة الرئيسية المُدرَجة في الإصدار 32.5.0 أو الإصدارات الأحدث من BoM).
في يوليو 2025، توقّفنا عن طرح إصدارات جديدة من وحدات KTX وأزلنا مكتبات KTX من الإصدار Firebase Android BoM (الإصدار 34.0.0).
لماذا يتم إجراء هذا التغيير؟
تلتزم Firebase بتوفير بيئة تتوافق بشكل كامل مع لغة Kotlin لمطوّري تطبيقات Android. توفّر عملية تحديث الحِزم المزايا التالية:
إدارة مبسطة للتبعيات: ما عليك سوى الاعتماد على وحدة واحدة، ما يغنيك عن التبديل بين الوحدة الرئيسية وإضافات Kotlin أو الاعتماد على كليهما.
تحسين توافق حِزم تطوير البرامج (SDK) مع لغة Kotlin: ستوفّر جميع حِزم تطوير البرامج (SDK) من Firebase لنظام التشغيل Android الآن توافقًا أفضل مع لغة Kotlin. سنضمّن جميع الميزات الجديدة المتوافقة مع Kotlin مباشرةً في وحداتنا الرئيسية.
تواريخ مهمة بشأن هذا التغيير
في تشرين الأول (أكتوبر) 2023
في أكتوبر 2023، تمت إضافة واجهات برمجة تطبيقات إضافات Kotlin (KTX) إلى الوحدات الرئيسية المعنية، ما يعني أنّه يمكنك الآن استخدام واجهات برمجة تطبيقات KTX مباشرةً من الوحدات الرئيسية عند استخدام الإصدار Firebase BoM 32.5.0 أو الإصدارات الأحدث أو إصدارات الوحدة الرئيسية المُدرَجة في الإصدار BoM 32.5.0 أو الإصدارات الأحدث.
في الوقت نفسه، تم إيقاف واجهات برمجة التطبيقات الخاصة بإضافة Kotlin (KTX) في وحدات KTX نهائيًا (راجِع ملاحظات الإصدار التي توضّح هذا التغيير). خلال
مرحلة الإيقاف النهائي،
ستستمر واجهات برمجة التطبيقات التي تم إيقافها نهائيًا في وحدات KTX في العمل وسيتم
الحفاظ عليها.
في يوليو 2025
في يوليو 2025، توقّفنا عن طرح إصدارات جديدة من وحدات KTX، وأزلنا وحدات KTX من Firebase BoM (بدءًا من BoM الإصدار 34.0.0).
سيستمر عمل أي إصدار سابق من وحدة KTX أو BoM، ولكنها أصبحت الآن خارج نطاق الصيانة.
وهذا يعني أنّنا لن نضيف إصلاحات للأخطاء أو تغييرات متوافقة مع الإصدارات السابقة أو ميزات جديدة إلى وحدات KTX. بدلاً من ذلك، سيتم إجراء جميع عمليات التطوير المستقبلية لمنصة Firebase على Android في الوحدات الرئيسية فقط (لكل من Java وKotlin).
كيفية نقل البيانات لاستخدام واجهات برمجة تطبيقات KTX من الوحدات الرئيسية
إذا كنت تستخدم واجهات برمجة تطبيقات إضافات Kotlin (KTX)، عليك إجراء التعديلات التالية في تطبيقك
لبدء استخدام واجهات برمجة التطبيقات من الوحدات الرئيسية بدلاً من وحدات KTX.
راجِع تبعيات Gradle للاعتماد على الوحدة الرئيسية بدلاً من وحدة KTX. على سبيل المثال، إذا كنت تستخدم Firebase Android BoM(ننصحك بذلك):
BEFORE
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 بواجهات برمجة التطبيقات التي تم نقلها في الوحدة الرئيسية ضمن الحزمة 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 ```"]]