Android ANR Spy is the most simplest library that helps android developers to detect ANRs.
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
dependencies {
implementation 'com.github.kibotu:ANR-Spy:-SNAPSHOT'
}
startSpying {
shouldThrowException = true // default false
timeout = 5000L // time limit to detect ANR
onWait {
//Total blocking time of main thread.
//Can be used for doing any action e.g. if blocked time is more than 5 seconds then
//restart the app to avoid raising ANR message because it will lead to down rank your app.
Log.e(TAG, "Waited: $it")
}
onAnrDetected {
// Is triggered when ANR is detected
Log.e(TAG, "$it")
}
}
Copyright 2023 Jan Rabe 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 https://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.