Pluto Exceptions is distributed through mavenCentral. To use it, you need to add the following Gradle dependency to your build.gradle file of you android app module.
Note: add the
no-op
variant to isolate the plugin from release builds.
dependencies {
debugImplementation "com.plutolib.plugins:exceptions:$plutoVersion"
releaseImplementation "com.plutolib.plugins:exceptions-no-op:$plutoVersion"
}
Now to start using the plugin, add it to Pluto
Pluto.Installer(this)
.addPlugin(PlutoExceptionsPlugin())
.install()
To intercept uncaught exceptions in your app, attach UncaughtExceptionHandler
to PlutoExceptions
PlutoExceptions.setExceptionHandler { thread, throwable ->
Log.d("exception_demo", "uncaught exception handled on thread: " + thread.name, throwable)
}
To intercept & report potential ANRs in your app, attach UncaughtANRHandler
to PlutoExceptions
PlutoExceptions.setANRHandler { thread, exception ->
Log.d("anr_demo", "potential ANR detected on thread: " + thread.name, exception)
}
You can also modify the Main thread response time, after which the above callback will be triggered.
PlutoExceptions.mainThreadResponseThreshold = 10_000
🎉 You are all done!
Now re-build and run your app and open Pluto, you will see the Exceptions plugin installed.
To open Exceptions plugin screen via code, use this
Pluto.open(PlutoExceptionsPlugin.ID)