Bugly Unity Plugin User Guide
Preparation before access
summary
General part integration steps
Download and import the Bugly Unity Plugin to the Unity project
-
Download the latest version Bugly Unity Plugin , Double click .unitypackage File, import relevant files of Plugin into your Unity project. Description of Download Package Directory Structure -
bugly_plugin_*.unitypackage -Bugly Unity Plugin package, providing C # exception capture function and native SDK interface encapsulation -
BuglySDK -Bugly native SDK, the native SDK that the Plugin package depends on -
BuglyUnitySample -Unity project example
-
Bugly_plugin_ *. unitypackage Directory Structure Description
Assets/Plugins/BuglyPlugins - Plugin script Assets/Plugins/BuglyPlugins/Android/libs - Native SDK (. jar) and NDK components (. so) that the Android platform depends on Assets/Bugly.framework - Native SDK static library that iOS platform depends on
be careful:
integrate Bugly Unity Plugin After that, it is also necessary to integrate the corresponding SDK components of the iOS or Android platform (already provided in the download package) The SDK components of iOS can be integrated in the exported Xcode project and the configuration can be modified (refer to IOS SDK User Guide ), or use XUPorter Plug in automatic integration Android SDK components can be integrated in the exported Android project and the configuration can be modified (refer to Android SDK User Guide ), or directly copy the content of the component to the project Plugins/Android directory, and modify the permission statement of AndroidManifest.xml
Initialize Bugly
-
Select the first or main scene( Scene ), call the following code in any script file (it is recommended to select a script loaded earlier) for initialization.
//Enable log printing of the SDK, and be sure to close it for the release version BuglyAgent.ConfigDebugMode (true); //Register log callback, and use 'Application RegisterLogCallback(Application. LogCallback) 'The way to register log callbacks // BuglyAgent. RegisterLogCallback (CallbackDelegate. Instance.OnApplicationLogCallbackHandler); #if UNITY_IPHONE || UNITY_IOS BuglyAgent.InitWithAppId ("Your App ID"); #elif UNITY_ANDROID BuglyAgent.InitWithAppId ("Your App ID"); #endif //If you confirm that the SDK has been initialized in the corresponding iOS project or Android project, you can just start the C # exception capture and reporting function in the script BuglyAgent.EnableExceptionHandler ();
Partial integration steps of iOS
Modify the compilation configuration of the exported Xcode project
You can refer to the configuration of this part IOS SDK User Guide
-
Switch to Build Phases Tab, add the following dependencies under the Link Binary With Libraries column:
libz.dylib -Used to compress reported data Security.framework -Used to store keychain SystemConfiguration.framework -Used to read system information when an exception occurs JavaScriptCore.framework -Set to Optional libc++.dylib -Libc++library dependency
be careful:
1) If the project has already added these dependencies, do not add them again
2) Via XUPorter Integration does not need to add configuration in Xcode
Android partial integration steps
Modify the configuration file AndroidManifest.xml of the Android project
You can refer to the configuration of this part Android SDK User Guide
Modify the permission statement in the AndroidManifest.xml file of the exported Android project, and add the following permissions:
<!-- Network communication --> <uses-permission android:name= "android.permission.INTERNET" /> <!-- Get network status --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Get MAC address --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- Get device information --> <uses-permission android:name= "android.permission.READ_PHONE_STATE" /> <!-- Optional permissions: --> <!-- Get logcat log --> <uses-permission android:name="android.permission.READ_LOGS" />
Note: If the permission statement has been added, do not add it again
API List
-
BuglyAgent.InitWithAppId(string) Initialize Bugly, and pass in the App ID obtained by registration on the Bugly website. Enable native code (Obj-C, C/C++, Java) exceptions, C # exception capture and reporting. If you have initialized Bugly in the corresponding iOS or Android project, you only need to call BuglyAgent.EnableExceptionHandler Enable C # exception capture and reporting. -
BuglyAgent.EnableExceptionHandler() Start C # exception log capture and reporting. By default, the level of LogError is automatically reported. Then the exception logs of LogError and LogException will be automatically captured and reported. Refer to LogSeverity for log level definition: {LogDebug LogWarning、LogAssert、LogError、LogException} -
BuglyAgent.RegisterLogCallback(BuglyAgent. LogCallbackDelegate) Register the LogCallbackDelegate callback method to process the system logs. If your application needs to call Application RegisterLogCallback (LogCallback) and other registered log callbacks can be replaced with this method. -
BuglyAgent.ConfigAutoReportLogLevel(LogSeverity) Set the level of automatically reporting log information. The default is LogError. Logs with>=LogError will be automatically captured and reported. Log levels are defined as LogDebug, LogWarning, LogAssert, LogError, LogException, etc -
BuglyAgent.ReportException (System. Exception, string) Report the captured C # exception, input the parameter exception object, and attach the description information -
BuglyAgent.ReportException (string, string, string) Report user-defined error information, enter error name, error reason, error stack and other information -
BuglyAgent.SetUserId (string) Set the user ID. If not, it defaults to Unknown. Called after initialization -
BuglyAgent.PrintLog (LogSeverity, string) Call the interface of the native SDK to print logs, and the printed log information will be reported together with the error information Called after initialization -
BuglyAgent.ConfigDebugMode (bool) Enable local debug log printing, which is off by default Note: Be sure to turn off the debug log printing function in the release version -
BuglyAgent.ConfigDefault (string, string, string, long) Modify the default configuration information of the application: channel number, version, user ID, Android initialization delay, etc. Called before initialization The default value of channel number is blank, Version Default -
Android app reads android: versionName in AndroidManifest.xml by default -
IOS applications read CFBundleShortVersionString and CFBundleVersion in the Info.plist file by default, and splice them into the CFBundleShortVersionString (CFBundleVersion) format, such as 1.0.1 (10)
The user ID defaults to Unknown Android initialization delay time, 0 by default, in milliseconds -
-
BuglyAgent.ConfigAutoQuitApplication (bool) Configure whether to exit the application immediately after capturing and reporting C # exception information to avoid more unexpected C # exceptions in the future. Called before initialization