The Unity ANR Plugin provides the access to the following APIs from Android SDK:
- ApplicationExitInfo to diagnose crashes and ANRs for Unity 2022 and older
- StrictMode to identify and prevent ANRs/deadlocks caused by I/O operations on the Main Thread
- Polling the memory stats for Unity 2021 and older
This will help you to diagnose your ANRs, on Unity versions 2022 and older. From Unity 2023, this functionality is already integrated into Unity.
-
Build the project in Android Studio Hedgehog (as the toolchain might not work with newer Android Studio versions)
-
Grab the
UnityANR-Plugin.aar
file (compiled plugin) from thePlugin/build/outputs/aar/
folder -
Import the
UnityANR-Plugin.aar
file into your Unity Editor -
Call the APIs!
unity-anr-plugin is distributed under the terms of the Apache License (Version 2.0). See the license for more information.