強制當機以測試導入作業
找出現有的
GameObject
,然後在其中加入下列指令碼。執行應用程式後,這個指令碼會在幾秒內造成測試當機。using System; using UnityEngine; public class CrashlyticsTester : MonoBehaviour { int updatesBeforeException; // Use this for initialization void Start () { updatesBeforeException = 0; } // Update is called once per frame void Update() { // Call the exception-throwing method here so that it's run // every frame update throwExceptionEvery60Updates(); } // A method that tests your Crashlytics implementation by throwing an // exception every 60 frame updates. You should see reports in the // Firebase console a few minutes after running your app with this method. void throwExceptionEvery60Updates() { if (updatesBeforeException > 0) { updatesBeforeException--; } else { // Set the counter to 60 updates updatesBeforeException = 60; // Throw an exception to test your Crashlytics implementation throw new System.Exception("test exception please ignore"); } } }
建構應用程式,並在建構完成後上傳符號資訊。
iOS+:Firebase Unity 編輯器外掛程式會自動設定 Xcode 專案,上傳符號檔。
Android:針對使用 IL2CPP 的 Android 應用程式,請執行 Firebase CLI
crashlytics:symbols:upload
指令,上傳符號檔。
執行應用程式。應用程式執行後,請查看裝置記錄,並等待
CrashlyticsTester
觸發例外狀況。iOS+:在 Xcode 的底部窗格中查看記錄。
Android:在終端機中執行以下指令,即可查看記錄:
adb logcat
。
前往 Firebase 控制台的Crashlytics 資訊主頁,查看測試當機情形。
如果重新整理控制台後,您在五分鐘內仍未看到測試當機,請嘗試啟用偵錯記錄 (下一節)。
啟用 Crashlytics 的偵錯記錄功能
如果 Crashlytics 資訊主頁未顯示測試當機,請使用 Crashlytics 的偵錯記錄檔,協助找出問題。
在應用程式初始化時加入下列程式碼,啟用 Firebase 的偵錯記錄:
Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Debug;
強制測試當機。本頁面的第一個部分說明如何執行這項操作。
如果五分鐘後,CrashlyticsFirebase 控制台的資訊主頁仍未顯示 Firebase 記錄或測試當機記錄,請將記錄輸出內容副本提供給 Firebase 支援團隊,我們會進一步協助您排解問題。
後續步驟
- 自訂當機報告設定,新增選擇加入回報、記錄、鍵,以及追蹤非致命錯誤。