반응형
Unity 에서 강제 Crash 테스트를 위한 코드 정리
1. Windows & Editor
- Utils.ForceCrash
docs.unity3d.com/2018.3/Documentation/ScriptReference/Diagnostics.Utils.ForceCrash.html
2. Android
using UnityEngine;
public class Crasher : MonoBehaviour
{
public void CrashOnAndroid()
{
// https://stackoverflow.com/questions/17511070/android-force-crash-with-uncaught-exception-in-thread
var message = new AndroidJavaObject("java.lang.String", "This is a test crash, ignore.");
var exception = new AndroidJavaObject("java.lang.Exception", message);
var looperClass = new AndroidJavaClass("android.os.Looper");
var mainLooper = looperClass.CallStatic<AndroidJavaObject>("getMainLooper");
var mainThread = mainLooper.Call<AndroidJavaObject>("getThread");
var exceptionHandler = mainThread.Call<AndroidJavaObject>("getUncaughtExceptionHandler");
exceptionHandler.Call("uncaughtException", mainThread, exception);
}
}
2020-10-22 12:52:46.462 31660-31863/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.neowiz.games.newmatgo, PID: 31660
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 2018.4.17f1
Device model : samsung SM-G887N
Device fingerprint: samsung/a8sqlteks/a8sqlteks:10/QP1A.190711.020/G887NKSU2CTI2:user/release-keys
Caused by: java.lang.Exception: This is a test crash, ignore.
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
at android.os.MessageQueue.next(MessageQueue.java:405)
at android.os.Looper.loop(Looper.java:197)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
forum.unity.com/threads/how-to-force-crash-on-android-to-test-crash-reporting-systems.653845/
반응형
'Works > Unity 3D' 카테고리의 다른 글
Unity C# DLL (0) | 2021.05.02 |
---|---|
[Unity] 프로젝트 Git 설정 (0) | 2021.02.02 |
[Unity] CinemachineVirtualCamera 이 작동하지 않을 경우 (0) | 2020.10.21 |
[Unity] Low Poly Map 간단히 만들기 (0) | 2020.10.15 |
[Unity] Mac 에서 Text Editor 로만 실행 되는 문제 (0) | 2020.10.14 |
댓글