تحديد المشاكل وحلّها الأسئلة الشائعة حول Unity وFirebase
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تقدّم هذه الصفحة نصائح ومعلومات لتحديد المشاكل وحلّها في Unity
التي قد تواجهها عند استخدام Firebase.
هل تواجه تحديات أخرى أو لا ترى مشكلتك موضّحة أدناه؟ يُرجى الاطّلاع على الأسئلة الشائعة الرئيسية حول Firebase للحصول على المزيد من الأسئلة الشائعة حول Firebase أو منتجات معيّنة.
مشكلة في ملف dex الفردي أثناء إنشاء تطبيق Android
أثناء إنشاء تطبيق Android، قد تواجه خطأ في الإنشاء مرتبطًا بملف dex واحد. ستبدو رسالة الخطأ مشابهة لما يلي، إذا تم ضبط مشروعك لاستخدام نظام الإصدار Gradle.
Cannot fit requested classes in a single dex file.
يتم استخدام ملفات Dalvik Executable (.dex) لتضمين مجموعة من تعريفات الفئات وبياناتها المساعدة المرتبطة بها لتطبيقات Android (.apk). ويقتصر ملف dex الواحد على الإشارة إلى 65,536 طريقة. سيتعذّر إنشاء الإصدار إذا تجاوز إجمالي عدد الطرق من جميع مكتبات Android في مشروعك هذا الحدّ.
أتاحت Unity ميزة التصغير
في الإصدار 2017.2، وهي تستخدم Proguard (أو أدوات أخرى في بعض إصدارات Unity)
لإزالة الرموز غير المستخدَمة، ما قد يقلّل العدد الإجمالي للطُرق
التي تتم الإشارة إليها في ملف dex واحد. يمكن العثور على الخيار في
إعدادات المشغّل > Android > إعدادات النشر > تصغير. قد تختلف الخيارات في إصدارات Unity المختلفة، لذا يُرجى الرجوع إلى مستندات Unity الرسمية.
إذا كان عدد الطرق المشار إليها لا يزال يتجاوز الحدّ، يمكنك تفعيل multidex. تتوفّر عدة طرق لتحقيق ذلك في Unity:
في حال تفعيل Custom Gradle Template ضمن Player Settings،
عدِّل mainTemplate.gradle.
إذا كنت تستخدم "استوديو Android" لإنشاء المشروع الذي تم تصديره، عدِّل ملف build.gradle على مستوى الوحدة.
مشاكل عند إنشاء إصدار لنظام التشغيل Android باستخدام الإصدار 23 من minSdkVersion
عند إنشاء إصدار لنظام التشغيل Android، إذا استهدفت الإصدار minSdkVersion 23، قد يتعذّر ذلك في خطوة إنشاء ملفات dex، وعادةً ما يحدث ذلك في مهمة Gradle :launcher:mergeExtDexDebug، حيث سيظهر الخطأ "تعذّر التحويل" لأحد مكتبات Android. يرجع ذلك إلى خطأ في أداة dex التلقائية في حزمة تطوير البرامج (SDK) لنظام التشغيل Android التي تستخدمها معظم برامج تعديل Unity، ويمكن إصلاح هذا الخطأ بعدة طرق مختلفة:
هذه هي الطريقة المقترَحة لإدارة الحِزم في Unity 2018.4 والإصدارات الأحدث.
استخدِم هذه الطريقة لتسهيل تحديثات الإصدارات المستقبلية ولتنظيف دليل Assets/.
في مشروع Unity، يجب استخدام طريقة استيراد واحدة فقط لإدارة جميع حِزم Firebase. يمكن استخدام التعليمات أدناه ليس فقط لتعديل إصدار الحِزم الفردية، ولكن أيضًا لنقل إدارة الحِزم إلى "مدير حِزم Unity" (UPM) (طريقة الاستيراد المُوصى بها)، إذا لزم الأمر.
تم استيراد الحِزم كملفات .unitypackage إلى المجلد Assets/
إذا كانت حِزم Firebase في الدليل Assets/، يتوفّر لك خياران لتعديل إصدار حزمة SDK:
الخيار 1 (يُنصح به): الانتقال إلى استخدام "مدير حِزم Unity" (متاح في Unity 2018.4 والإصدارات الأحدث)
على الرغم من أنّ هذه الطريقة تتطلّب إعدادًا أوليًا أكثر من مواصلة استخدام سير عمل
.unitypackage، إلا أنّها توفّر سهولة في إجراء تحديثات لاحقة على إصدار حزمة SDK.
الخيار 2: مواصلة استخدام ملفات .unitypackage لاستيرادها إلى الدليل Assets/
إذا نزّلت firebase_unity_sdk.zip من موقع Firebase الإلكتروني، تأكَّد من استيراد جميع .unitypackages من مجلد dotnet الصحيح.
إذا كنت تستخدم Unity 2019 أو إصدارًا أحدث، استورِد من المجلد dotnet4.
بخلاف ذلك، اختَر إصدار وقت تشغيل البرامج النصية في إعدادات المشغّل،
وإذا كان الخيار مضبوطًا على ".NET 3.x"، استورِد من المجلد dotnet3.
يجب أن تتم معالجة الكتابة فوق إصدارات الحزمة التي تم استيرادها سابقًا تلقائيًا من خلال "أداة إدارة التبعيات الخارجية" (التي يتم تضمينها تلقائيًا عند استيراد .unitypackages في Firebase).
ومع ذلك، إذا تعذّر إكمال هذه العملية التلقائية، عليك حذف المجلدات التالية يدويًا ثم إعادة محاولة تنفيذ خطوة الاستيراد المذكورة أعلاه.
تاريخ التعديل الأخير: 2025-09-03 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-09-03 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\nThis page offers tips and troubleshooting for Unity-specific issues\nthat you might encounter when using Firebase.\n\nHave other challenges or don't see your issue outlined below? Make sure to check\nout the [main Firebase FAQ](/support/faq) for more pan-Firebase or\nproduct-specific FAQ.\n\nAn issue with single dex while building Android app\n\nWhile building Android app, you may encounter a build failure related to having\na single dex file. The error message looks similar to the following, if your\nproject is configured to use the Gradle build system. \n\n Cannot fit requested classes in a single dex file.\n\nDalvik Executable (`.dex`) files are used to hold a set of class definitions\nand their associated adjunct data for Android applications (`.apk`). A single dex\nfile is limited to reference to 65,536 methods. The build will fail if the total\nnumber of methods from all Android libraries in your project exceeds this limit.\n\nUnity introduced [Minification](https://docs.unity3d.com/2017.2/Documentation/Manual/android-gradle-overview.html)\nin 2017.2, which uses Proguard (or other tools in some versions of Unity)\nto strip out unused code, which can reduce the total number of\nreferenced methods in a single dex file. The option can be found in\n**Player Settings \\\u003e Android \\\u003e Publishing Settings \\\u003e Minify**. The options may\ndiffer in different version of Unity so refer to the official Unity\ndocumentation.\n\nIf the number of referenced methods still exceeds the limit, another option is\nto enable `multidex`. There are multiple ways to achieve this in Unity:\n\n- If `Custom Gradle Template` under `Player Settings` is enabled, modify `mainTemplate.gradle`.\n- If you use Android Studio to build the exported project, modify module-level `build.gradle` file.\n\nMore details can be found in [the multidex user guide](https://developer.android.com/studio/build/multidex).\n\nIssues when building for Android with minSdkVersion 23\n\nWhen building for Android, if you target `minSdkVersion` 23, it might fail on\nthe dexing step, usually in the Gradle task ':launcher:mergeExtDexDebug', where\nit will say it \"Failed to transform\" one of the Android libraries. This is\ncaused because of a bug in the default dex tool in the Android SDK that most\nUnity editors use, and can be fixed in a few different ways:\n\n- Set the `minSdkVersion` to 24.\n- Turn on Android minification, in **Player Settings \\\u003e Android \\\u003e Publishing Settings \\\u003e Minify**\n- Specify a different version of the dex tool by adding this to your `settingsTemplate.gradle` file:\n\n buildscript {\n repositories {\n mavenLocal()\n maven { url 'https://maven.google.com' }\n mavenCentral()\n }\n dependencies {\n classpath 'com.android.tools:r8:8.3.37'\n }\n }\n\nIssues when building for iOS with Cocoapods\n\nWhen building for iOS, Cocoapod installation may fail with an error about the\nlanguage locale, or UTF-8 encoding. There are currently several different ways\nto work around the issue.\n\n- From the terminal, run `pod install` directly, and open the resulting\n xcworkspace file.\n\n- Downgrade the version of Cocoapods to 1.10.2. The issue exists only in\n version 1.11 and newer.\n\n- In your `~/.bash_profile` or equivalent, add `export LANG=en_US.UTF-8`\n\nHow to update the version of Firebase Unity SDKs\n\nThe process to update the versions of Firebase Unity SDKs depends on how they\nwere initially imported. Here are the two alternative import methods:\n\n- Importing `.unitypackage` files under your project's `Assets/` directory\n- Importing using the [Unity Package Manager](https://docs.unity3d.com/Manual/Packages.html) (UPM)\n - This is the recommended way to manage packages in Unity 2018.4+.\n - Use this method to make future version updates easier and your `Assets/` directory cleaner.\n\nIn your Unity project, you should only use one import method to manage all your\nFirebase packages. The instructions below can be used to not only update the\nversion of individual packages, but also, if needed, to migrate package\nmanagement to UPM (the recommended import method).\n| **Note:** Before updating the SDK version, manually create a local backup. Afterward, if the project fails to build or run properly in the editor or on target platforms, you can restore from the backup.\n\n\u003cbr /\u003e\n\nPackages imported as `.unitypackage` files into the\n`Assets/` directory\n\n\u003cbr /\u003e\n\nIf Firebase packages are in the `Assets/` directory, you have two options for\nupdating the SDK version:\n\n- *Option 1 *(recommended)**: Migrate to use UPM (available in Unity 2018.4+)\n\n - Follow the Firebase-provided [instructions to migrate package management\n to UPM](/docs/unity/setup-alternative#alternative_migrate_to_upm).\n - While this method requires more initial setup than continuing to use the `.unitypackage` workflow, it pays off in ease of subsequent SDK version updates.\n- *Option 2* : Continue to use `.unitypackage` files to import them into the\n `Assets/` directory\n\n 1. Import\n [each of the packages](/docs/unity/setup-alternative#alternative_individual_unitypackages)\n for the updated version.\n\n If you download [firebase_unity_sdk.zip](/docs/unity/setup) from the\n Firebase website, make sure that you import all `.unitypackages` from\n the correct `dotnet` folder.\n - If you're using Unity 2019 or later, import from the `dotnet4` folder.\n - Otherwise, select *Scripting Runtime Version* in *Player Settings* , and if it's set to \".NET 3.x\", import from the `dotnet3` folder.\n 2. Overwriting of the previously imported package versions should be\n handled automatically by the External Dependency Manager (which is\n automatically included when you import the Firebase `.unitypackages`).\n\n However, if and ONLY if this automatic process fails, you'll need to\n manually delete the following folders and then re-try the above import\n step again.\n - `Assets/Editor Default Resources/Firebase`\n - `Assets/ExternalDependencyManager`\n - `Assets/Firebase`\n - `Assets/Parse`\n - `Assets/Plugins/iOS/Firebase`\n\n\u003cbr /\u003e\n\nPackages managed by UPM\n\n\u003cbr /\u003e\n\nIf Firebase packages are managed by UPM,\n[import the newer SDK version as a `.tgz`](/docs/unity/setup-alternative#alternative_unity_package_manager).\nThis import will automatically overwrite the previous version.\n| **Note:** Make sure to upgrade ALL Firebase Unity packages and their dependencies (including `com.google.firebase.app`) to the same version. The only exception is the dependency on the External Dependency Manager, which should be updated to the [`com.google.external-dependency-manager` version](https://developers.google.com/unity/archive#firebase_app_core) that corresponds to the updated version of your Firebase Unity packages."]]