1. 程式人生 > >Unity +Bugly 實現bug收集以及分析

Unity +Bugly 實現bug收集以及分析

應用場景:Android+IOS 客戶端收集異常反饋資料,方便維護。

1:登陸Bugly官網,註冊賬號並“新建產品”,可以獲取到一個“APP ID”,之後有用。

將:BuglyBridge/ios/BuglyBridge 資料夾拖到專案Plugins/IOS中,BuglySDK/IOS/Bugly.framework拖到

專案assest目錄中

3:Unity中新增Bugly初始化程式碼:初始程式碼就這麼簡單,簡單的新增一些測試程式碼

privatevoidinitBugly()
    {
BuglyAgent.ConfigDebugMode(true);
#if UNITY_IPHONE||UNITY_IOS
BuglyAgent

.InitWithAppId("你的APPID");
#elif UNITY_ANDROID
        BuglyAgent.InitWithAppId("你的APPID");
#endif

BuglyAgent.EnableExceptionHandler();

    }

privatevoidOnGUI()
    {
if(GUI.Button(newRect(100,100,100,50),"陣列超範圍")){
byte[] byteArr = newbyte[20];
byteArr[21] = 0x11;
        }
if(GUI.Button(newRect(100,200,100,50),"Null")){
GameObject

obj = null;
obj.transform.SetParent(this.transform);
        }

    }

4:打包Xcode工程:

新增相關依賴包:

  • libz.dylib - 用於對上報資料進行壓縮
  • Security.framework - 用於儲存keychain
  • SystemConfiguration.framework - 用於讀取異常發生時的系統資訊
  • JavaScriptCore.framework - 設定為Optional
  • libc++.dylib - libc++庫依賴

5:填坑

(1)Not found class 'Bugly',解決方法:刪除並重新新增Bugly.framework依賴就可以

[BuglyAgent] <Debug> -  : Enable the log message print to console

2018-06-06 15:45:56.908010+0800 gps[5156:2416485] <Error> BuglyAgentV2: Not found class 'Bugly'

[BuglyAgent] <Debug> -  : Initialized with app id: e8429856ea

[BuglyAgent] <Debug> -  : Register the log callback in Unity 5.6.4f1

[BuglyAgent] <Debug> -  : BuglyAgent has already been initialized.

Setting up 1 worker threads for Enlighten.

  Thread -> id: 16ed8f000 -> priority: 1