From 0449f77ffa632045cc67438a2a71a7da7e3336c0 Mon Sep 17 00:00:00 2001 From: Mysochenko Yuriy Date: Thu, 15 Sep 2022 10:19:18 +0300 Subject: [PATCH] add acra to send crash reports --- app/build.gradle | 3 ++ .../ActivityManagerApplication.kt | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 4d75bbb1..df1c35ff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,6 +90,9 @@ dependencies { implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" implementation "androidx.vectordrawable:vectordrawable:1.1.0" + def acra_version = "5.9.6" + implementation "ch.acra:acra-mail:$acra_version" + implementation "ch.acra:acra-dialog:$acra_version" def glide_version = "4.13.2" implementation "com.github.bumptech.glide:glide:$glide_version" kapt "com.github.bumptech.glide:compiler:$glide_version" diff --git a/app/src/main/java/com/sdex/activityrunner/ActivityManagerApplication.kt b/app/src/main/java/com/sdex/activityrunner/ActivityManagerApplication.kt index 4517290e..86ca030f 100644 --- a/app/src/main/java/com/sdex/activityrunner/ActivityManagerApplication.kt +++ b/app/src/main/java/com/sdex/activityrunner/ActivityManagerApplication.kt @@ -5,6 +5,11 @@ import android.content.Context import androidx.multidex.MultiDex import com.sdex.activityrunner.preferences.AppPreferences import dagger.hilt.android.HiltAndroidApp +import org.acra.ReportField +import org.acra.config.dialog +import org.acra.config.mailSender +import org.acra.data.StringFormat +import org.acra.ktx.initAcra import timber.log.Timber @HiltAndroidApp @@ -23,5 +28,28 @@ class ActivityManagerApplication : Application() { override fun attachBaseContext(base: Context) { super.attachBaseContext(base) MultiDex.install(this) + + initAcra { + buildConfigClass = BuildConfig::class.java + reportFormat = StringFormat.JSON + reportContent = listOf( + ReportField.APP_VERSION_CODE, + ReportField.APP_VERSION_NAME, + ReportField.ANDROID_VERSION, + ReportField.PHONE_MODEL, + ReportField.STACK_TRACE, + ) + mailSender { + mailTo = "activitymanagerapp@gmail.com" + subject = "Activity Manager crash report" + } + dialog { + title = "Crash report" + text = "App crashed. Do you want to send the email report?" + resTheme = R.style.AppDialogTheme + positiveButtonText = "Yes" + negativeButtonText = "No" + } + } } }