Change permission settings in the AndroidManifest.xml configuration file of the Android project.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
#include "CrashSightAgent.h" ///Please include this header file
#if DEBUG
CrashSightAgent::ConfigDebugMode (true);
#endif
// Set the domain name for reporting. Please fill in according to project publishing requirements. (required)
CrashSightAgent::ConfigCrashServerUrl("UploadUrl");
// Set the target APP ID for reporting and initialize. You can find the APP ID from More->Product Settings->Product Info of the management console. (required)
CrashSightAgent::InitWithAppId("AppID");
Domestic public cloud:
Overseas public cloud:
Execute 1.1 and 1.2 of Integration in Unreal. For the rest of the initialization, refer to(https://crashsight.qq.com/docs/zh/crashsight/sdkDocuments/mobile-sdk.html “SDK Development and Integration for Mobile Applications open in new window.”)
public static void InitWithAppId (string appId)
Note: Execute initialization. Initialize as early as possible to enable crash detection and reporting features.
Parameter | Type | Note |
---|---|---|
appId | string | APP ID of registered projects |
public static void ConfigDebugMode (bool enable)
Note: Whether to enable debugging mode. Off by default. After enabling, some logs will be printed, but it can help locate issues during tests.
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
enable | bool | Enabling switch for debugging |
public static void ConfigCrashServerUrl (const char * crashServerUrl)
Note: Set domain name for reporting.
Note: Call it before the InitWithAppId interface.
The domain name of domestic public environment is as follows:
A direct CrashSight domain name Integration is different from an indirect one using MSDK. Make sure you follow the above domain name to reconfigure. For other environment domain name, please consult the Integration contact.
Parameter | Type | Note |
---|---|---|
crashServerUrl | const char * | Target domain name of reporting |
public static void ConfigCrashReporter (int logLevel)
Note: Set custom log reporting level. Off=0, Error=1, Warn=2, Info=3, Debug=4
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
logLevel | int | Log level |
static void ConfigDefault (const char *channel, const char *version, const char * user, long delay);
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
channel | const char * | Channel |
version | const char * | App Version |
user | const char * | User ID |
delay | long | Delay(s) |
public static void SetDeviceId(const char *deviceId)
Note: Starting from version 4.2.9, CrashSight Android no longer obtains AndroidId, and uses uuid as device ID by default
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
deviceId | const char * | Device ID |
public static void SetDeviceModel(const char *deviceModel)
Note: Set phone model
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
deviceModel | const char * | Phone model |
public static void ReportException(int type, const char * name, const char * reason, const char * stackTrace, const char * extras, bool quit, bool isDumpNativeStack= false)
Note: Active reporting of error info
Parameter | Type | Note |
---|---|---|
type | int | Exception type, C#: 4, js: 5, lua: 6 |
name | const char * | Exception Name |
reason | const char * | Exception Info |
stackTrace | const char * | Stack |
extras | const char * | Other Info |
quit | bool | Whether to quit |
isDumpNativeStack | bool | whether to dump the Native stack of the current thread |
View page:
extras: Crash Details->Trace Data->extraMessage.txt
Native stack: Crash Details->Trace Data->trace.zip
public static void ReportExceptionJson(int type, const char *exceptionName, const char *exceptionMsg, const char *exceptionStack, const char *paramsJson, bool isDumpNativeStack =false)
Note: Active reporting of error info
Parameter | Type | Note |
---|---|---|
type | int | Exception type, C#: 4, js: 5, lua: 6 |
exceptionName | const char * | Exception Name |
exceptionMsg | const char * | Exception Info |
exceptionStack | const char * | Stack |
paramsJson | const char * | Other Info, Json string of map code |
quit | bool | Whether to quit |
isDumpNativeStack | bool | whether to dump the Native stack of the current thread |
View page:
paramsJson: Crash Details->Trace Data->extraMessage.txt
Native stack: Crash Details->Trace Data->trace.zip
Other: time used to report the error
Android | iOS | |||
---|---|---|---|---|
Attachment size | Dump stack | Do not dump stack | Dump stack | Do not dump stack |
100K | [0.498881]s | [0.003127]s | [0.117762]s | [0.001172]s |
10K | [0.464859]s | [0.000730]s | [0.115362]s | [0.000445]s |
1K | [0.477934]s | [0.000189]s | [0.117078]s | [0.000293]s |
public static void SetUserId (const char *userId)
Parameter | Type | Note |
---|---|---|
userId | const char * | User ID |
public static void SetScene (int sceneId)
Parameter | Type | Note |
---|---|---|
sceneId | int | Scene ID |
static void SetAppVersion(const char *appVersion)
Note: Set app version number
For Android, the versionName property of AndroidManifest.xml file is used by default
For iOS, configure Info.plist, {CFBundleShortVersionString}.{CFBundleVersion} into the app version number.
Note: Call it before the InitWithAppId interface.
Parameter | Type | Note |
---|---|---|
appVersion | const char * | Version Number |
public static void AddSceneData (const char *key, const char *value)
Note: Set the Key-Value data customized by the user. It will be reported together with exception info when sending the crash. Each key shouldn’t exceed 100 characters, each value shouldn’t exceed 1000 characters, and the total length (all keys+all values) shouldn’t exceed 64KB for Android, 128KB for iOS.
View page: Crash Details->Trace Data->valueMapOthers.txt
Parameter | Type | Note |
---|---|---|
key | const char * | Key |
value | const char * | Value |
public static void PrintLog (LogSeverity level, const char * format, ...)
Note: The custom log shouldn’t exceed 30KB.
Parameter | Type | Note |
---|---|---|
level | LogSeverity | Log level |
format | const char * | Log format |
public static void SetCrashObserver(UQMCrashObserver *crashObserver)
Note: The callback function is called when a crash is detected. Customize the CSCrashCallBack class, inherit UQMCrashObserver, and implement the OnCrashExtraMessageNotify, OnCrashExtraDataNotify methods
Parameter | Type | Note |
---|---|---|
crashObserver | UQMCrashObserver | UQMCrashObserver Integration |
Example:
CSCrashCallBacks.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UQMCrash.h"
/**
*
*/
using namespace UQM;
class CRASHSIGHTDEMO_UE4_API CSCrashCallBacks : public UQMCrashObserver
{
public:
CSCrashCallBacks();
~CSCrashCallBacks();
const char* OnCrashExtraMessageNotify();
long OnCrashExtraDataNotify(const InnerCrashRet &crashRet);
};
CSCrashCallBacks.cpp
#include "CSCrashCallBacks.h"
CSCrashCallBacks::CSCrashCallBacks()
{
}
CSCrashCallBacks::~CSCrashCallBacks()
{
}
const char* CSCrashCallBacks::OnCrashExtraMessageNotify() {
char str1[] = "this is extra message.";
char *retValue = SAFE_MALLOC(strlen(str1) + 1, char); // 128*1024 characters at most. The exceeding part will be discarded
strcpy(retValue, str1);
return retValue;
}
long CSCrashCallBacks::OnCrashExtraDataNotify(const InnerCrashRet &crashRet) {
char str[] = "this is extra data.";
strcpy(crashRet.data, str); // Already assigned 128*1024 bytes of storage. No need to assign more. The exceeding part will be discarded
return strlen(str);
}
OnCrashExtraMessageNotify’s returned content for Android is on the “Crash Analysis-Trace Data-extraMessage.txt” page.
OnCrashExtraDataNotify’s returned content for Android is on the “Crash Analysis-Trace Data-userExtraByteData” page, Base64 code OnCrashExtraMessageNotify’s returned content for iOS is on the “Crash Analysis-Trace Data-crash_attach.log” page.
For iOS, the OnCrashExtraDataNotify interface isn’t called
public static void SetLogPath(const char *logPath)
Note: Set an upload path for log after a crash. Read permission is required
Parameter | Type | Note |
---|---|---|
logPath | const char * | Log absolute path |
View page: Crash Details-Trace Data-Client Reporting Log
public static void SetCrashLogObserver(UQMCrashLogObserver *crashObserver)
Note: The callback function is called when uploading logs. Customize the MyCrashLogCallback class, inherit UQMCrashLogObserver, and implement the OnCrashSetLogPathNotify, OnCrashLogUploadResultNotify methods
Parameter | Type | Note |
---|---|---|
crashObserver | UQMCrashLogObserver | Subclass of UQMCrashLogObserver |
Example:
MyCrashLogCallback.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UQMCrash.h"
using namespace UQM;
/**
*
*/
class UQMCRASHSIGHTTEST_API MyCrashLogCallback: public UQMCrashLogObserver
{
public:
MyCrashLogCallback();
~MyCrashLogCallback();
// Set log path callback
const char* OnCrashSetLogPathNotify(int crashType);
// Callback for notifying the log uploading results
void OnCrashLogUploadResultNotify(int crashType, int result);
};
CSCrashCallBacks.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyCrashLogCallback.h"
MyCrashLogCallback::MyCrashLogCallback()
{
}
MyCrashLogCallback::~MyCrashLogCallback()
{
}
// Set log path callback
// @param crashType Crash type, 0: Java crash, 2: Native crash
// @result Absolute path of log. If non-empty, it overwrites the path of SetCrashLogObserver interface
const char *MyCrashLogCallback::OnCrashSetLogPathNotify(int crashType)
{
const char *path = "/data/data/packagename/app_crashSight/log.txt";
return path;
}
// Callback for notifying the log uploading results
// @param crashType Crash type, 0: Java crash, 2: Native crash
// @param retust Log uploading result, 0: successful, other: failed
void MyCrashLogCallback::OnCrashLogUploadResultNotify(int crashType, int result)
{
}
CrashSight Test Interface
Test Java crash
static void TestJavaCrash();
Test Object-C crash
static void TestOcCrash();
Test Native crash
static void TestNativeCrash();
The above is an introduction to SDK Integration, crash reporting and verifying, but to see readable restored stacks on the page, you need to upload the corresponding symbol table. Please see Symbol Table Uploading Tools Guide.