简单集成bugly
1.在module的build.gradle里面
//bugly 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
2.在module的build.gradle里面的顶部
apply plugin: 'bugly' bugly { appId = '21557gegebe6' // 注册时分配的App ID appKey = '8c55e41ed-4017-b167-f31e90862316' // 注册时分配的App Key debug = true }
3.在应用的build.gradle里面的dependencies里(这是为了让bugly可以打印出错误所在行的)
//bugly符号表 classpath 'com.tencent.bugly:symtabfileuploader:latest.release'
4.在Application的oncreate()里面
//bugly的初始化过程 context = getApplicationContext(); Context context = getApplicationContext(); // 获取当前包名 String packageName = context.getPackageName(); // 获取当前进程名 String processName = getProcessName(android.os.Process.myPid()); // 设置是否为上报进程 CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context); strategy.setUploadProcess(processName == null || processName.equals(packageName)); // 初始化Bugly CrashReport.initCrashReport(context, "21557gegebe6", true, strategy); //bugly的测试代码 // CrashReport.testJavaCrash();
当然,在最初的时候肯定要去bugly官网填写应用信息的,从而得到应用的appid和appkey,用来填在第二步和第四步的。页面不方便展示了,怎么样,是不是很简单,然后就可以愉快的查看奔溃信息了。