Awesome
<p align="center"> <img src='https://cdn-images-1.medium.com/max/2600/1*7CVLni2XSYNFzy7dRHLtsQ.png'/> </p> <p align="center"> <a href='https://bintray.com/osama-raddad/maven/fire-crasher?source=watch' alt='Get automatic notifications about new "fire-crasher" versions'><img src='https://www.bintray.com/docs/images/bintray_badge_color.png'></a> </p> <p align="center"> <a href="http://www.methodscount.com/?lib=com.osama.firecrasher%3Afirecrasher%3A1.0"><img src="https://img.shields.io/badge/Methods count-83-e91e63.svg"/></a> <a href="http://www.methodscount.com/?lib=com.osama.firecrasher%3Afirecrasher%3A1.0"><img src="https://img.shields.io/badge/Size-10 KB-e91e63.svg"/></a> </p> <p align="center"> <a href='https://ko-fi.com/A4763RZL' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi2.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a> </p> </p> <p align="center"> <a href='https://www.codacy.com/app/osama-s-raddad/FireCrasher?utm_source=github.com&utm_medium=referral&utm_content=osama-raddad/FireCrasher&utm_campaign=Badge_Grade' target='_blank'><img src='https://api.codacy.com/project/badge/Grade/4da668c9125b401babee42dbb9283f22' border='0' alt='Codacy Badge' /></a> </p> </p> <p align="center"> <a href='https://travis-ci.org/osama-raddad/FireCrasher' target='_blank'><img src='https://travis-ci.org/osama-raddad/FireCrasher.svg?branch=master' border='0' alt='Build Status' /></a> </p>FireCrasher
FireCrasher is designed to handle the uncaught exceptions and utilize a RECOVERY process from the Exception Without exiting from the application.
The Problem
"The study, carried out online by uSamp, found that freezing (76%), crashing (71%) and slow responsiveness (59%) were the primary bugbears when it came to app problems, with heavy battery usage (55%) and too many ads (53%) also mentioned. Users stressed that performance mattered the most on banking apps (74%) and maps (63%), with the latter no doubt much to the chagrin of Apple, which has had some difficulty with its own maps software on iOS 6. For almost every respondent (96%) said that they would write a bad review on an under-par app, while 44% said that they would delete the app immediately. Another 38% said that they would delete the app if it froze for more than 30 seconds with 32% and 21% respectively indicating that they would moan about the app to their friends or colleagues in person or over Facebook and Twitter. A considerable 18% would delete an app immediately if it froze for just five seconds, but 27% said that they would persist with the app if they paid for it. Those experiencing bad apps urged developers to fix the problem (89%) first and foremost, followed by offering easy refunds (65%) and a customer service number (49%)."
The Solution
Every developer knows that shit happens, and at some point you will ship a random exception to the production code (application) thus you might risk losing a 44% of the affected users, this where Firecrasher comes in, it utilizes a recovery sequence to limit and chicaneries the crash consequences on three different levels; the first level is the random behavioral crash (occasional crash) that would be solved with just restarting the crashed activity if the restarted activity kept crashing for three consecutive times, the second level of the sequence will start executing at this stage the crashed is considered dead and the library checks if there are other activities in the backstack it invokes the onBackPressed() if there are no activities in the backstack then level three takes effect in restarting the whole application from the default activity. Moreover, it works without losing any crash reports.
Requirements
Min SDK version 14
Install
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.osama-raddad:FireCrasher:2.0.0'
}
Usage
to use the library add this code to Application class :
class App : Application() {
override fun onCreate() {
super.onCreate()
FireCrasher.install(this);
}
}
or you can use your logic, For example :
class App : Application() {
override fun onCreate() {
super.onCreate()
FireCrasher.install(this, object : CrashListener() {
override fun onCrash(throwable: Throwable) {
Toast.makeText(this@App, throwable.message, Toast.LENGTH_SHORT).show()
// start the recovering process
recover()
//you need to add your crash reporting tool here
//Ex: Crashlytics.logException(throwable);
}
})
}
}
to detarmein the crash level before starting the recovery you can use:
FireCrasher.install(this, object : CrashListener() {
override fun onCrash(throwable: Throwable) {
evaluate { activity, crashLevel ->
recover {
Toast.makeText(this@App, "recover", Toast.LENGTH_LONG).show()
}
}
//you need to add your crash reporting tool here
//Ex: Crashlytics.logException(throwable);
}
})
Contributing
We welcome contributions to FireCrasher!
- ⇄ Pull requests and ★ Stars are always welcome.
Let me know!
I’d be really happy if you sent me links to your projects where you use my library. Just send an email to osama.s.raddad@gmail.com And do let me know if you have any questions or suggestion regarding the library.
License
Copyright 2019, Osama Raddad
Licensed 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://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.