Android ANR Spy is the most simplest library that helps android developers to detect ANRs.
- Detect ANR
- Detect a function which is approaching ANR limit and send report to firebase prior to ANR occurrence.
when a developer do most heavy jobs on UI thread (more than 5 seconds usually) and UI thread still receieve more request/events for doing a task then Android system raises ANR message. This is extremely bad effect on your app and may lead to the failure of your business.
Google recommends/suggests your app on play store. If your app raises too many ANRs then your app will be ranked down
- Normal on UI Thread in any activity = 5 secs
- BroadCast = 10 sec
- Service = 20 sec
Note: Sample app is included in the project. Just clone the repo
implementation("io.github.farimarwat:anrspy:2.0")
//CrashLytics Object to get non-fatel report
val crashlytics = FirebaseCrashlytics.getInstance()
//Building spy agent
val anrSpyAgent = ANRSpyAgent.Builder(this )
.setTimeOut(3000) //Time out for ANR to be considered
.setTicker(500) //Check interval. Keep this as minimum as possible, 200 ms will be best
.setThrowException(false) //Setting true will crash the app if time out limit exceeds
.setFirebaseCrashLytics(crashlytics) // setting crashlytics object
.build()
anrSpyAgent.start()
version 2.0
- ANR detection with annotation method removed
- ANR detection algorithm changed
- A lot of extra functions removed
version 1.3
- Get details of methods which is related to main app package that causes anrs via "onAnrDetected" extra paramater
- A bug fixed (classnotfoundexception)
version 1.2 (beta)
- Annotation added to trace a specific method for ANR
- Store annotated methods report in firebase analytics
version 1.0 Initial release
If you want to donate then you are welcome to buy me a cup of tea via PATREON because this encourages me to give you more free stuff and continue to maintain this library