خدمات گزارش دهی مانند Android vitals ، Firebase Crashlytics ، و Backtrace (یک شریک تایید شده Unity) ثبت خطا و تجزیه و تحلیل خطا را برای بازی شما در مقیاس ارائه می کنند. SDK های خدمات گزارش دهی را در اوایل چرخه توسعه در بازی خود ادغام کنید. تجزیه و تحلیل کنید که کدام سرویس گزارش بهترین با نیازها و بودجه بازی شما مطابقت دارد.
سرویسهای گزارشگیری مختلف روشهای متفاوتی برای گرفتن ANR دارند. یک سرویس گزارش دوم را برای افزایش شانس به دست آوردن داده های معتبر برای حمایت از تصمیم شما در رفع ANR اضافه کنید.
یکپارچه سازی SDK های گزارش بر عملکرد بازی یا اندازه APK تأثیر نمی گذارد.
نمادها را تجزیه و تحلیل کنید
گزارشهای سرویس گزارشدهی خود را تجزیه و تحلیل کنید و بررسی کنید که آیا ردیابیهای پشته در قالب قابل خواندن توسط انسان هستند یا خیر. برای اطلاعات بیشتر به بازی های Symbolicate Android و ANR for Unity مراجعه کنید.
شکل 2. Crashlytics که شناسه ساخت و نمادهای libil2cpp.so از دست رفته را نشان می دهد.
چگونه شناسه ساخت نماد را بررسی کنیم
اگر سیستم گزارشدهی شناسه ساخت گمشده را نشان میدهد اما نمادهای ساخت همچنان در ذخیرهسازی ماشین ساخت وجود دارند، میتوان شناسه ساخت نمادها را بررسی کرد و سپس آنها را در سرویس گزارش آپلود کرد. در غیر این صورت، برای آپلود فایل های نماد نیاز به ساخت جدید است.
در ویندوز یا macOS:
به پوشه نمادها بر اساس باطن اسکریپت خود بروید (به Resolution مراجعه کنید :)
از دستور زیر استفاده کنید (در ویندوز، از Cygwin برای اجرای برنامه readelf استفاده کنید)
استفاده از Grep برای فیلتر کردن خروجی متن اختیاری است
وقتی stack trace تابعی را در کتابخانه libil2cpp.so نشان میدهد، این خطا در کد C# رخ میدهد که به C++ تبدیل میشود. کتابخانه libil2cpp.so نه تنها کد بازی شما، بلکه افزونه ها و بسته ها را نیز دارد.
نام فایل C++ از نام اسمبلی تعریف شده در پروژه Unity پیروی می کند. در غیر این صورت، نام فایل دارای نام پیش فرض Assembly-C# است. به عنوان مثال، شکل 3 خطای فایل Game.cpp را نشان می دهد (که با رنگ آبی مشخص شده است) که نام تعریف شده در فایل Assembly Definition است. Logger نام کلاس است (با رنگ قرمز برجسته شده) در اسکریپت C# و به دنبال آن نام تابع (با رنگ سبز برجسته شده است). در نهایت نام کاملی است که مبدل IL2CPP ایجاد کرده است (به رنگ نارنجی برجسته شده است).
شکل 3. پشته تماس پروژه را از Backtrace آزمایش کنید.
کد بازی خود را با انجام موارد زیر بررسی کنید:
پروژه C# را برای هر کد مشکوک بررسی کنید. معمولاً استثناهای کنترل نشده C# باعث ANR یا خرابی برنامه نمی شوند. با این حال، مطمئن شوید که کد در موقعیت های مختلف به درستی اجرا می شود. بررسی کنید که آیا کد از ماژول موتور شخص ثالث استفاده می کند یا خیر، و بررسی کنید که آیا نسخه اخیر این خطا را ایجاد کرده است یا خیر. علاوه بر این، بررسی کنید که آیا اخیرا یونیتی را بهروزرسانی کردهاید یا اینکه خطا فقط در دستگاههای خاصی رخ میدهد.
بازی را به عنوان یک پروژه اندروید استودیو صادر کنید . با دسترسی کامل به کد منبع C# تبدیل شده بازی خود، می توانید عملکردی را که باعث ANR شده است، پیدا کنید. کد ++C با کد سی شارپ شما بسیار متفاوت به نظر می رسد، و تبدیل کد به ندرت مشکل دارد. اگر چیزی پیدا کردید، یک تیکت پشتیبانی به Unity ارسال کنید.
موتور یونیتی برای توقف اجرای خود یک بازه زمانی دارد. بار کاری بیش از حد در این تماس ها می تواند باعث ANR شود.
گزارش ها یا خرده نان را به بخش هایی از کد اضافه کنید تا تجزیه و تحلیل داده های خود را بهبود ببخشید.
از Unity Profiler برای بررسی عملکرد بازی استفاده کنید. نمایه کردن برنامه شما همچنین می تواند راهی عالی برای کمک به شناسایی تنگناهایی باشد که ممکن است باعث ANR شوند.
یک راه عالی برای شناسایی عملیات I/O طولانی در رشته اصلی استفاده از حالت سخت است.
Android Vitals یا سابقه خدمات گزارش دهی دیگر را تجزیه و تحلیل کنید و نسخه های منتشر شده بازی را که خطا برای آنها بیشتر اتفاق می افتد بررسی کنید. کد منبع خود را در تاریخچه کنترل نسخه خود مرور کنید و تغییرات کد را بین نسخه ها مقایسه کنید. اگر چیزی مشکوک پیدا کردید، هر تغییر یا اصلاح احتمالی را به صورت جداگانه آزمایش کنید.
سابقه گزارش ANR Google Play را برای دستگاهها و نسخههای Android دریافتکننده بیشترین ANR بررسی کنید. اگر دستگاهها یا نسخهها قدیمی هستند، اگر این کار بر سودآوری بازی تأثیری نمیگذارد، احتمالاً میتوانید با خیال راحت آنها را نادیده بگیرید. داده ها را با دقت مطالعه کنید زیرا گروه خاصی از کاربران دیگر نمی توانند بازی شما را انجام دهند. برای اطلاعات بیشتر، به داشبورد توزیع مراجعه کنید.
کد منبع بازی را مرور کنید تا مطمئن شوید که هیچ کدی را که ممکن است باعث مشکل شود تماس نمیگیرید، برای مثال، اگر به درستی استفاده نشود، پایان میتواند مخرب باشد. برای کسب اطلاعات بیشتر در مورد توسعه Android، به راهنمای توسعه دهندگان Android مراجعه کنید.
پس از بررسی دادهها و صادرات بیلد بازی به اندروید استودیو، با کدهای C و C++ سر و کار دارید و بنابراین میتوانید از ابزارهایی فراتر از راهحلهای استاندارد Unity مانند Android Memory Profiler ، Android CPU Profiler و perfetto بهرهمند شوید.
کد موتور یونیتی
برای اینکه بدانید آیا یک ANR در سمت موتور Unity اتفاق میافتد، libUnity.so یا libMain.so را در stack traces بررسی کنید. اگر آنها را پیدا کردید، مراحل زیر را انجام دهید:
اگر چیزی پیدا نکردید، برای رفع مشکل ، باگ را ثبت کنید . یک ردیابی پشته نمادین ارائه دهید تا مهندسان موتور بهتر بتوانند خطا را درک کرده و آن را حل کنند.
بررسی کنید که آیا آخرین نسخه Unity LTS بهبودهایی در رابطه با مشکلات شما ایجاد کرده است یا خیر. اگر چنین است، بازی خود را برای استفاده از آن نسخه ارتقا دهید. (این راه حل ممکن است فقط برای برخی از توسعه دهندگان امکان پذیر باشد.)
اگر کد شما بهجای پیشفرض از یک Activity سفارشی استفاده میکند، کد جاوا را بررسی کنید تا مطمئن شوید که فعالیت مشکلی ایجاد نمیکند.
SDK شخص ثالث
بررسی کنید که همه کتابخانههای شخص ثالث بهروز باشند و گزارشی از خرابی یا ANR برای آخرین نسخه Android نداشته باشند.
به انجمن Unity بروید تا ببینید آیا هر گونه خطایی قبلاً در نسخه بعدی برطرف شده است یا راه حلی توسط Unity یا یکی از اعضای انجمن ارائه شده است.
گزارش Google Play ANR را مرور کنید و مطمئن شوید که خطا قبلاً توسط Google شناسایی نشده است. Google از برخی ANR ها آگاه است و به طور فعال برای رفع آنها کار می کند.
کتابخانه سیستم
کتابخانههای سیستم معمولاً از کنترل توسعهدهنده دور هستند، اما درصد قابل توجهی از ANR را نشان نمیدهند. فراتر از تماس با توسعهدهنده کتابخانه یا اضافه کردن گزارشها برای محدود کردن مشکل، حل کردن ANR کتابخانه سیستم دشوار است.
دلایل خروج
ApplicationExitInfo یک API Android برای درک علل ANR است. اگر بازی شما از Unity 6 یا بالاتر استفاده می کند، می توانید مستقیماً با ApplicationExitInfo تماس بگیرید. برای نسخههای قدیمیتر Unity، باید افزونه خود را پیادهسازی کنید تا تماسهای ApplicationExitInfo از Unity فعال شود.
Crashlytics همچنین از ApplicationExitInfo استفاده می کند. با این حال، پیادهسازی خودتان به شما کنترل دقیقتری میدهد و شما را قادر میسازد اطلاعات مرتبطتری را درج کنید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-26 بهوقت ساعت هماهنگ جهانی."],[],[],null,["Solving [ANRs](/topic/performance/vitals/anr) in your Unity game is a systematic process:\n**Figure 1.** Steps to solve ANRs in Unity games.\n\nIntegrate reporting services\n\nReporting services such as [Android vitals](/topic/performance/vitals), [Firebase\nCrashlytics](https://firebase.google.com/products/crashlytics), and [Backtrace](https://backtrace.io/) (a certified Unity\npartner) provide error logging and analysis for your game at scale. Integrate\nreporting services SDKs into your game early in the development cycle. Analyze\nwhich reporting service best fits your game needs and budget.\n\nDifferent reporting services have different ways of capturing ANRs. Include a\nsecond reporting service to increase the chance of obtaining valid data to\nsupport your decision in fixing ANRs.\n\nIntegrating reporting SDKs doesn't impact game performance or APK size.\n\nAnalyze symbols\n\nAnalyze the reports from your reporting service and check\nwhether the stack traces are in human-readable format. See [Symbolicate Android\ncrashes and ANR for Unity games](/games/engines/unity/unity-symbolicate) for more information.\n**Figure 2.** Crashlytics showing build ID and missing `libil2cpp.so` symbols.\n\n**How to check symbol build ID**\n\nIf the reporting system shows the missing build ID but the build symbols still\nexist in the build machine storage, it's possible to check the build ID of the\nsymbols and then upload them to the reporting service. Otherwise, a new build is\nrequired to upload the symbol files.\n\nOn Windows or macOS:\n\n1. Navigate to the symbols folder based on your [scripting\n backend](https://support.unity.com/hc/en-us/articles/115000292166-Symbolicate-Android-crash) (see **Resolution** :)\n 1. Use the following command (on Windows, use [Cygwin](https://www.cygwin.com/) to run the `readelf` utility)\n 2. Grep usage is optional to filter the text output\n 3. Look for Build ID\n\n readelf -n libil2cpp.so | grep 'Build ID'\n Build ID: b42473fb7449e44e0182dd1f580c99bab0cd8a95\n\nInspect game code\n\nWhen the stack trace shows a function in the `libil2cpp.so` library,\nthe error happened in the C# code, which is [converted to C++](https://docs.unity3d.com/Manual/overview-of-dot-net-in-unity.html).\nThe `libil2cpp.so` library has not only your game code but also plugins and packages.\n\nThe C++ filename follows the assembly name defined in the Unity project.\nOtherwise, the filename has the default Assembly-C# name. For example,\nfigure 3 shows the error on file `Game.cpp` (highlighted in blue), which\nis the name defined in the Assembly Definition file. `Logger` is the\nclass name (highlighted in red) in the C# script, followed by the\nfunction name (highlighted in green). Finally is the full name\nthat the IL2CPP converter generated (highlighted in orange).\n**Figure 3.** Test project call stack from Backtrace.\n\nInspect your game code by doing the following:\n\n- Examine the C# project for any suspicious code. Usually, C# unhandled exceptions don't cause an ANR or application crash. Even so, ensure the code runs properly in different situations. Check whether the code uses a third-party engine module, and analyze whether a recent release introduced the error. In addition, review whether you have recently updated Unity or whether the error only happens on specific devices.\n- [Export](https://docs.unity3d.com/Manual/android-export-process.html) the game as an Android Studio project. With complete access to your game's converted C# source code, you can find the function that's causing the ANR. The C++ code looks very different from your C# code, and the code conversion rarely has an issue. If you do find something, file a support ticket to Unity.\n- Review the game source code and ensure that any logic running in the [OnApplicationFocus()](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html) and [OnApplicationPause()](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html) callbacks is appropriately cleaned up.\n - The Unity engine has a timeout to pause its execution; excessive workload on these callbacks can cause an ANR.\n - Add logs or breadcrumbs to parts of the code to enhance your data analysis.\n- Use the [Unity Profiler](https://docs.unity3d.com/Manual/Profiler.html) to investigate the game's performance. Profiling your app can also be a great way to help identify bottlenecks that might be causing the ANR.\n- A great way to identify long I/O operations on the main thread is to use [strict mode](/topic/performance/vitals/anr#strict_mode).\n- Analyze the Android Vitals or another reporting service history and check the release versions of the game for which the error is happening the most. Review your source code in your version control history and compare code changes between releases. If you find something suspicious, experiment with each change or potential fix individually.\n- Examine the Google Play ANR reporting history for the devices and Android versions receiving the most ANRs. If the devices or versions are outdated, chances are you can safely ignore them if doing so doesn't impact the game's profitability. Study the data carefully since a particular group of users will no longer be able to play your game. For more information, see [Distribution\n dashboard](/about/dashboards).\n- Review the game source code to ensure you are not calling any code that might cause an issue, for example, [finish](/reference/android/app/Activity#finish()) can be destructive if not used correctly. See the [Android developer guides](/guide) to learn more about Android development.\n- After reviewing the data and exporting the game build to Android Studio, you're dealing with C and C++ code, and so you can take full advantage of tools beyond Unity's standard solutions, such as [Android Memory Profiler](/studio/profile/memory-profiler), [Android CPU Profiler](/studio/profile/cpu-profiler), and [perfetto](/tools/perfetto).\n\n| **Warning:** Avoid custom code loading---both native and managed---with [Play Asset Delivery](/guide/playcore/asset-delivery), as code loading causes hard-to-debug ANRs.\n\nUnity engine code\n\nTo know if an ANR is happening on the Unity engine side of things, check for\n`libUnity.so` or `libMain.so` in the stack traces. If you find them, take the\nfollowing steps:\n\n- First, search the community channels ([Unity Forums](https://forum.unity.com/), [Unity\n Discussions](https://discussions.unity.com/), [Stackoverflow](https://stackoverflow.com/questions/tagged/unity-game-engine?tab=Newest)%7B:.external%7D)).\n- If you do not find anything, [file a bug](https://unity.com/releases/editor/qa/bug-reporting) to resolve the problem. Provide a symbolicated stack trace so the engine's engineers can better understand and solve the error.\n- Check whether the latest [Unity\n LTS](https://unity.com/releases/editor/qa/lts-releases) has made improvements related to your issues. If so, upgrade your game to use that version. (This solution may be possible only for some developers.)\n- If your code uses a custom [`Activity`](/reference/android/app/Activity) instead of the default, review the Java code to ensure the activity is not causing any issues.\n\nThird-party SDK\n\n- Check that all third-party libraries are up to date and don't have reports of crashes or ANRs for the latest version of Android.\n- Go to the [Unity Forums](https://forum.unity.com/) to see if any errors have already been resolved in a later version or if a workaround has been provided by Unity or a community member.\n- Review the [Google Play ANR report](https://support.google.com/googleplay/android-developer/answer/9859174) and ensure the error has not already been identified by Google. Google is aware of some ANRs and is actively working to fix them.\n\n| **Note:** The [Google Play SDK Console](https://play.google.com/sdk-console/about/) allows SDK providers to access usage statistics, crash and ANR (application not responding) reporting, and tools to help guide app developers in adopting SDK versions that fix quality issues and comply with Play policies. You can submit bug reports and feedback to the Google Play SDK Console to help the SDK provider improve their SDK.\n\nSystem library\n\nSystem libraries usually are far from the developer's control, but they don't\nrepresent a significant percentage of ANRs. Beyond contacting the library\ndeveloper or adding logs to narrow down the problem, system library ANRs are\ndifficult to resolve.\n\nExit reasons\n\n[`ApplicationExitInfo`](/reference/android/app/ApplicationExitInfo) is an Android API for understanding ANR causes.\nIf your game is using [Unity 6 or later](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Android.IApplicationExitInfo.html) you can call `ApplicationExitInfo`\ndirectly. For older Unity versions, you need to implement your own plugin\nto enable `ApplicationExitInfo` calls from Unity.\n\nCrashlytics also uses `ApplicationExitInfo`; however, your own\nimplementation gives you finer control and enables you to include\n[more relevant information](/reference/kotlin/android/app/ActivityManager#setprocessstatesummary)."]]