با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه نکات و عیبیابی برای مشکلات خاص Unity را ارائه میدهد که ممکن است هنگام استفاده از Firebase با آن مواجه شوید.
چالش های دیگری دارید یا مشکل خود را در زیر نمی بینید؟ حتماً سؤالات متداول اصلی Firebase را برای سؤالات متداول pan-Firebase یا محصول خاص بررسی کنید.
مشکل تک دکس هنگام ساخت اپلیکیشن اندروید
در حین ساخت اپلیکیشن اندروید، ممکن است با مشکل ساخت مرتبط با داشتن یک فایل dex مواجه شوید. اگر پروژه شما برای استفاده از سیستم ساخت Gradle پیکربندی شده باشد، پیام خطا مشابه شکل زیر است.
Cannot fit requested classes in a single dex file.
فایلهای اجرایی Dalvik ( .dex ) برای نگهداری مجموعهای از تعاریف کلاس و دادههای کمکی مرتبط با آنها برای برنامههای Android ( .apk ) استفاده میشوند. یک فایل dex تنها به 65536 روش محدود می شود. اگر تعداد کل روشها از تمام کتابخانههای Android در پروژه شما از این حد بیشتر شود، ساخت شکست میخورد.
Unity Minification را در سال 2017.2 معرفی کرد که از Proguard (یا ابزارهای دیگر در برخی نسخههای Unity) برای حذف کدهای استفاده نشده استفاده میکند که میتواند تعداد کل روشهای ارجاعشده را در یک فایل dex کاهش دهد. این گزینه را می توان در تنظیمات پخش کننده > Android > تنظیمات انتشار > Minify پیدا کرد. گزینه ها ممکن است در نسخه های مختلف Unity متفاوت باشند، بنابراین به اسناد رسمی Unity مراجعه کنید.
اگر تعداد روشهای ارجاعشده همچنان از حد مجاز فراتر رفت، گزینه دیگری فعال کردن multidex است. برای رسیدن به این هدف در Unity راه های مختلفی وجود دارد:
اگر Custom Gradle Template در Player Settings فعال است، mainTemplate.gradle تغییر دهید.
اگر از Android Studio برای ساخت پروژه صادر شده استفاده می کنید، فایل build.gradle در سطح ماژول را تغییر دهید.
هنگام ساختن برای اندروید، اگر minSdkVersion 23 را هدف قرار دهید، ممکن است در مرحله dexing، معمولاً در وظیفه Gradle ':launcher:mergeExtDexDebug'، که در آن میگوید «تبدیل نشد» یکی از کتابخانههای Android، شکست بخورد. این به دلیل وجود اشکال در ابزار پیشفرض dex در Android SDK است که اکثر ویرایشگران Unity از آن استفاده میکنند و میتوان آن را به چند روش مختلف برطرف کرد:
minSdkVersion را روی 24 تنظیم کنید.
کوچکسازی اندروید را در تنظیمات Player > Android > Publishing Settings > Minify روشن کنید
با افزودن این مورد به فایل settingsTemplate.gradle ، نسخه دیگری از ابزار dex را مشخص کنید:
هنگام ساخت برای iOS، نصب Cocoapod ممکن است با خطا در مورد زبان محلی یا رمزگذاری UTF-8 شکست بخورد. در حال حاضر چندین راه مختلف برای حل این مشکل وجود دارد.
از ترمینال، pod install مستقیماً اجرا کنید و فایل xcworkspace حاصل را باز کنید.
نسخه Cocoapods را به 1.10.2 تنزل دهید. این مشکل فقط در نسخه 1.11 و جدیدتر وجود دارد.
در ~/.bash_profile یا معادل آن، export LANG=en_US.UTF-8 اضافه کنید
نحوه به روز رسانی نسخه Firebase Unity SDK
فرآیند بهروزرسانی نسخههای Firebase Unity SDK بستگی به نحوه وارد کردن اولیه آنها دارد. در اینجا دو روش جایگزین واردات وجود دارد:
وارد کردن فایلهای .unitypackage در فهرست Assets/ پروژه شما
این روش توصیه شده برای مدیریت بسته ها در Unity 2018.4+ است.
از این روش برای آسانتر کردن بهروزرسانی نسخههای آینده و پاککننده Assets/ Directory خود استفاده کنید.
در پروژه یونیتی خود، فقط باید از یک روش واردات برای مدیریت تمام بسته های Firebase خود استفاده کنید. دستورالعملهای زیر را میتوان نه تنها برای بهروزرسانی نسخه بستههای جداگانه، بلکه در صورت نیاز، برای انتقال مدیریت بسته به UPM (روش واردات توصیهشده) استفاده کرد.
بستههای وارد شده بهعنوان فایلهای .unitypackage به فهرست Assets/
اگر بستههای Firebase در فهرست Assets/ قرار دارند، دو گزینه برای بهروزرسانی نسخه SDK دارید:
گزینه 1 (توصیه می شود) : برای استفاده از UPM مهاجرت کنید (موجود در Unity 2018.4+)
در حالی که این روش به نصب اولیه بیشتری نسبت به ادامه استفاده از گردش کار .unitypackage نیاز دارد، اما بهروزرسانیهای بعدی نسخه SDK به راحتی جواب میدهد.
گزینه 2 : به استفاده از فایلهای .unitypackage برای وارد کردن آنها به فهرست Assets/ ادامه دهید.
اگر firebase_unity_sdk.zip را از وبسایت Firebase دانلود میکنید، مطمئن شوید که همه .unitypackages را از پوشه dotnet صحیح وارد کردهاید.
اگر از Unity 2019 یا جدیدتر استفاده می کنید، از پوشه dotnet4 وارد کنید.
در غیر این صورت، Scripting Runtime Version را در Player Settings انتخاب کنید و اگر روی ".NET 3.x" تنظیم شده است، از پوشه dotnet3 وارد کنید.
بازنویسی نسخههای بستهای که قبلاً وارد شدهاند باید بهطور خودکار توسط External Dependency Manager انجام شود (که بهطور خودکار هنگام وارد کردن .unitypackages گنجانده میشود).
با این حال، اگر و فقط اگر این فرآیند خودکار با شکست مواجه شد، باید پوشه های زیر را به صورت دستی حذف کنید و سپس دوباره مرحله واردات بالا را دوباره امتحان کنید.
تاریخ آخرین بهروزرسانی 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."]]