腾讯Bugly 收集异常
https://bugly.qq.com/v2/index
账号:qq号(891542962)
android {
defaultConfig {
ndk {
// 设置支持的SO库架构
abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
}
dependencies {
compile 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.1.9
compile 'com.tencent.bugly:nativecrashreport:latest.release' //其中latest.release指代最新Bugly NDK版本号,也可以指定明确的版本号,例如3.0
}
在项目根目录的gradle.properties文件中添加:
android.useDeprecatedNdk=true
- 在AndroidManifest.xml中添加权限
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<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" />
<uses-permission android:name="android.permission.READ_LOGS" />
private void setBugly(final Context appContext) {
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(appContext);
strategy.setCrashHandleCallback(new CrashReport.CrashHandleCallback() {
public Map<String, String> onCrashHandleStart(int crashType, String errorType,
String errorMessage, String errorStack) {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
map.put("Key", "Value");
//发生异常,执行的操作
return map;
}
@Override
public byte[] onCrashHandleStart2GetExtraDatas(int crashType, String errorType,
String errorMessage, String errorStack) {
try {
return "Extra data.".getBytes("UTF-8");
} catch (Exception e) {
return null;
}
}
});
CrashReport.initCrashReport(getApplicationContext(), Constant.BUGLY_ID, true, strategy);
}