You first have to add the library to your Android project. For this you have to add Jitpack
to your repositories
- In the
build.gradle.kts
at project level
allprojects {
repositories {
maven("https://jitpack.io")
}
}
- In the
build.gradle.kts
at module/app level
dependencies {
// ...
implementation("com.github.BobbyESP:Crashy:<version>")
}
First, for being able to catch any non-caught exceptions you will have to create a class extending the Application
class from Android
For this create, for example in the root folder of your app module source a class called App
:
class App: Application() {
override fun onCreate() {
super.onCreate()
}
}
And now that you have the file like that, just leaves calling the setupCrashHandler()
function in the onCreate()
function
class App: Application() {
override fun onCreate() {
super.onCreate()
setupCrashHandler()
}
}
The only changes that you have to do in your manifest for the library to work are:
<application
android:name=".App">
<!-- The rest of your code -->
<activity
android:name="com.bobbyesp.crashhandler.CrashHandlerActivity"
android:label="CrashHandlerActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.<Your app theme>" />
</application>
And done!