版权声明:本文为徐代龙原创文章,未经徐代龙允许不得转载。网络资源网站:xudailong.cc 福利网站:www.00reso.com 公众号:蛇崽网盘教程资源 https://blog.csdn.net/xudailong_blog/article/details/86490003
这篇文章主要记录在项目中集成腾讯Bugly来进行项目中bug的手机,以及通过在后台管理页面对bug查看,进行bug的处理,具体的可以参考腾讯Bugly官方文档
集成步骤
- 去腾讯Bugly官网申请账号,或者是直接用个人的QQ号,这里尽量使用公司的账号申请,同时,Bugly的申请不需要身份验证之类的,只需要绑定手机号,进行个短信验证即可。
- 申请完后,就下载腾讯Bugly的SDK:腾讯BuglySDK
- 或者你可以省略第二步,直接使用第三步进行SDK的配置
(1)项目的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// 腾讯bugly
classpath 'com.tencent.bugly:symtabfileuploader:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
(2)app的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
//腾讯bug管理插件
apply plugin: 'bugly'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.bugly.demo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
/** 腾讯bugly */
ndk {
// 设置支持的 SO 库构架
abiFilters 'armeabi', 'x86'// 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64'
}
multiDexEnabled true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//腾讯bug管理平台
compile 'com.tencent.bugly:crashreport:2.6.0'
compile 'com.tencent.bugly:nativecrashreport:3.3.0'
}
注意:这里的NDK放置位置在defaultConfig
栏目下
(3)在BaseApplication的OnCreate中进行Bugly的初始化,这里需要涉及到腾讯Bugly的AppID
@Override
public void onCreate() {
super.onCreate();
initBugly();
}
/**
* 初始化腾讯bug管理平台
*/
private void initBugly() {
/* Bugly SDK初始化
* 参数1:上下文对象
* 参数2:APPID,平台注册时得到,注意替换成你的appId
* 参数3:是否开启调试模式,调试模式下会输出'CrashReport'tag的日志
* 注意:如果您之前使用过Bugly SDK,请将以下这句注释掉。
*/
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
strategy.setAppVersion(AppUtils.getAppVersionName());
strategy.setAppPackageName(AppUtils.getAppPackageName());
strategy.setAppReportDelay(20000); //Bugly会在启动20s后联网同步数据
/* 第三个参数为SDK调试模式开关,调试模式的行为特性如下:
输出详细的Bugly SDK的Log;
每一条Crash都会被立即上报;
自定义日志将会在Logcat中输出。
建议在测试阶段建议设置成true,发布时设置为false。*/
CrashReport.initCrashReport(getApplicationContext(), "xxxxxx", true ,strategy);
Bugly.init(getApplicationContext(), "xxxxxx", false);
}
以上就完成了腾讯Bugly的集成,为了查看是否集成成功,这时候我们可以随意定义一个空引用出来。
例如:
编译重新运行,然后会在Bugly控制台上看到:
以上就是整个步骤,如果还有不大懂明白的地方,可以移步腾讯Bugly官方文档