diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6c0a4d97..f2a50aef 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -112,6 +112,9 @@ dependencies { // logger implementation(libs.stream.log) + // crash tracer & restorer + implementation(libs.snitcher) + // firebase implementation(platform(libs.firebase.bom)) implementation(libs.firebase.analytics) diff --git a/app/src/main/kotlin/com/skydoves/chatgpt/ChatGPTApp.kt b/app/src/main/kotlin/com/skydoves/chatgpt/ChatGPTApp.kt index 3d654afa..8c85bc80 100644 --- a/app/src/main/kotlin/com/skydoves/chatgpt/ChatGPTApp.kt +++ b/app/src/main/kotlin/com/skydoves/chatgpt/ChatGPTApp.kt @@ -17,7 +17,17 @@ package com.skydoves.chatgpt import android.app.Application +import com.skydoves.snitcher.Snitcher import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp -class ChatGPTApp : Application() +class ChatGPTApp : Application() { + + override fun onCreate() { + super.onCreate() + + // install Snitcher to trace global exceptions and restore the app. + // https://github.com/skydoves/snitcher + Snitcher.install(this) + } +} diff --git a/benchmark/src/main/kotlin/com/skydoves/chatgpt/benchmark/BaselineProfileGenerator.kt b/benchmark/src/main/kotlin/com/skydoves/chatgpt/benchmark/BaselineProfileGenerator.kt index 60df332d..cfb84ec7 100644 --- a/benchmark/src/main/kotlin/com/skydoves/chatgpt/benchmark/BaselineProfileGenerator.kt +++ b/benchmark/src/main/kotlin/com/skydoves/chatgpt/benchmark/BaselineProfileGenerator.kt @@ -16,6 +16,8 @@ package com.skydoves.chatgpt.benchmark +import android.os.Build +import androidx.annotation.RequiresApi import androidx.benchmark.macro.junit4.BaselineProfileRule import org.junit.Rule import org.junit.Test @@ -23,14 +25,16 @@ import org.junit.Test /** * Generates a baseline profile which can be copied to `app/src/main/baseline-prof.txt`. */ +@RequiresApi(Build.VERSION_CODES.P) class BaselineProfileGenerator { @get:Rule val baselineProfileRule = BaselineProfileRule() @Test fun startup() = - baselineProfileRule.collectBaselineProfile( - packageName = "com.skydoves.chatgpt" + baselineProfileRule.collect( + packageName = "com.skydoves.chatgpt", + includeInStartupProfile = true ) { pressHome() // This block defines the app's critical user journey. Here we are interested in diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0bda1abe..e9898d1f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,6 +38,7 @@ retrofit = "2.9.0" sandwich = "1.3.8" moshi="1.15.0" spotless = "6.7.0" +snitcher = "1.0.1" webviewInspector = "1.0.2" firebaseBom = "32.1.1" @@ -86,6 +87,7 @@ kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx- kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" } sandwich = { group = "com.github.skydoves", name = "sandwich", version.ref = "sandwich" } +snitcher = { group = "com.github.skydoves", name = "snitcher", version.ref = "snitcher" } retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } moshi = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" } moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }