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:2.0.1-beta'
releaseImplementation 'com.plutolib.plugins:exceptions-no-op:2.0.1-beta'
}
Now to start using the plugin, add it to Pluto
Pluto.Installer(this)
.addPlugin(PlutoExceptionsPlugin("exceptions"))
.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 are all done!
Now re-build and run your app and open Pluto, you will see the Exceptions plugin installed.