CrashReporter是捕获应用程序崩溃并将其保存在文件中的便捷工具

网友投稿 1360 2022-10-31

CrashReporter是捕获应用程序崩溃并将其保存在文件中的便捷工具

CrashReporter是捕获应用程序崩溃并将其保存在文件中的便捷工具

CrashReporter

CrashReporter is a handy tool to capture app crashes and save them in a file.

Here is an article related to this library.

Why CrashReporter?

While developing features we get crashes and if device is not connected to logcat we miss the crash log. In worst case scenario we might not be able to reproduce the crash and endup wasting effort. This library captures all unhandled crashes and saves them locally on device. I found a problem with other libraries that they capture crashes and then uploads them to server and sometimes few crashes aren't logged to server. That's the purpose of this library use it as a debug feature to capture crashes locally and immediately.

Run the sample

Crash Reporter APIs

Track all crashesUse Log Exception API to log ExceptionAll crashes and exceptions are saved in deviceChoose your own path to save crash reports and exceptionsShare Instantly crash log with your team with other device data.

Crash reporter doesn't takes any permission or root access

Using Crash Reporter Library in your application

add below dependency in your app's gradle

compile 'com.balsikandar.android:crashreporter:1.1.0'

If you only want to use Crash reporter in debug builds only add

debugCompile 'com.balsikandar.android:crashreporter:1.1.0'

Note : If you get error like this "no resource identifier found for attribute 'alpha' in package 'android'" use below dependency. This may happen due to two different versions of design support library as CrashReporter also uses design support library internally.

debugCompile('com.balsikandar.android:crashreporter:1.1.0') { exclude group: 'com.android.support', module: 'design'}

Crash Reporter On Duty

It'll capture all unhandled crashes and write them to a file in below directory

/Android/data/your-app-package-name/files/crashReports

To save crashes in a path of your choice, add below line in onCreate method of your Application class

CrashReporter.initialize(this, crashReporterPath);

Note: You don't need to call CrashReporter.initialize() if you want logs to be saved in default directory. If you want to use external storage then add storage permission in you manifest file.

Using log Exception API

If you want to capture exceptions then you can use below API

for ex :

try { // Do your stuff} catch (Exception e) { CrashReporter.logException(e);}

Pass exception thrown in below method

logException(Exception exception)

To get default crash reports path

CrashUtil.getDefaultPath()

you can access all crash/exception log files from this path and upload them to server for your need. Remember it's default path if you provide your own path you know where to find the logs...

TODO

Context awareness to track crashes and fix them. Identify crashes and categorise them in groups

Find this project useful ? ❤️

Support it by clicking the ⭐ button on the upper right of this page. ✌️

That's it for now

Contact - Let's connect and share knowledge

TwitterGithubMediumFacebook

License

Copyright (C) 2016 Bal SikandarCopyright (C) 2011 Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

Contributing to this Repo

Create a pull request and Dive In.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:springBoot解决static和@Component遇到的bug
下一篇:自定义spring boot starter三部曲之一:准备工作
相关文章

 发表评论

暂时没有评论,来抢沙发吧~