Android 压力测试 (记录bug)

经高人指点,腾讯的良心之作  bugly (网站首页  https://bugly.qq.com)  

有些bug是偶尔才出现的,所以让开发者措手不及。而bugly 可以把bug信息和输出的所有信息即时传到网上,良心之作啊 

其实官网的文档写的很清楚,但是是pdf版的  ,为了便于查找和复制我才写此文章。

以下为官方官方提供的 说明 和 jar包

http://download.csdn.net/detail/guang_liang_/9815090

http://download.csdn.net/detail/guang_liang_/9815087

下面是步骤:

1、导包,自动导包即可

2、配置 AndroidManifest.xml 

添加权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
3、在工程 app/proguard-rules.pro 中加入

#bugly
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
4、在application中加入初始化

CrashReport.initCrashReport(getApplicationContext(),"0995cc0211",true);
//3个参数 分别为 context、你的id、和开发者模式(即true则在android monitor显示bugly的提示信息,
false 则关闭) 


5、随便加一个监听,然后加入bugly提供的报错点

findViewById(R.id.activity_main_text).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        CrashReport.testJavaCrash();
    }
});
这样j就 OK了,是不是很简单



正常的话会显示提示信息

04-15 08:11:20.586 20073-20073/? W/CrashReport: Bugly debug模式开启,请在发布时把isDebug关闭。 -- Running in debug model for 'isDebug' is enabled. Please disable it when you release.
04-15 08:11:20.586 20073-20073/? E/CrashReport: --------------------------------------------------------------------------------------------
04-15 08:11:20.586 20073-20073/? W/CrashReport: Bugly debug模式将有以下行为特性 -- The following list shows the behaviour of debug model: 
04-15 08:11:20.586 20073-20073/? W/CrashReport: [1] 输出详细的Bugly SDK的Log -- More detailed log of Bugly SDK will be output to logcat;
04-15 08:11:20.586 20073-20073/? W/CrashReport: [2] 每一条Crash都会被立即上报 -- Every crash caught by Bugly will be uploaded immediately.
04-15 08:11:20.586 20073-20073/? W/CrashReport: [3] 自定义日志将会在Logcat中输出 -- Custom log will be output to logcat.
04-15 08:11:20.586 20073-20073/? E/CrashReport: --------------------------------------------------------------------------------------------


点击按钮报错信息

E/CrashReport: java.lang.RuntimeException: This Crash create for Test! You can go to Bugly see more detail!
                                                                           at com.tencent.bugly.crashreport.CrashReport.testJavaCrash(BUGLY:136)
                                                                           at com.example.kys_29.bugly.MainActivity$1.onClick(MainActivity.java:20)
                                                                           at android.view.View.performClick(View.java:4780)
                                                                           at android.view.View$PerformClick.run(View.java:19866)
                                                                           at android.os.Handler.handleCallback(Handler.java:739)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                           at android.os.Looper.loop(Looper.java:135)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:372)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
04-15 08:11:24.308 20073-20073/com.example.kys_29.bugly E/CrashReport: #++++++++++++++++++++++++++++++++++++++++++#
04-15 08:11:24.321 20073-20073/com.example.kys_29.bugly D/CrashReport: [Database] deleted t_lr data 1
04-15 08:11:24.333 20073-20073/com.example.kys_29.bugly D/CrashReport: [Database] insert t_lr success.
04-15 08:11:24.333 20073-20073/com.example.kys_29.bugly I/CrashReportInfo: [crash] a crash occur, handling...
04-15 08:11:24.348 20073-20073/com.example.kys_29.bugly D/CrashReport: [Database] insert t_cr success.
04-15 08:11:24.348 20073-20073/com.example.kys_29.bugly D/CrashReport: insert t_cr success!

猜你喜欢

转载自blog.csdn.net/guang_liang_/article/details/70184860