[null,null,["最后更新时间 (UTC):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)."]]