Explorar el Código

Added crash reporting for play builds

Vadik Sirekanyan hace 2 años
padre
commit
1c424b9414

+ 1 - 0
.github/workflows/build.yml

@@ -47,3 +47,4 @@ jobs:
           files: |
             app/build/outputs/apk/*/*/*release*.apk
             app/build/outputs/bundle/*/*release*.aab
+            app/build/outputs/mapping/*/mapping.txt

+ 4 - 0
app/build.gradle.kts

@@ -57,6 +57,7 @@ android {
         warningsAsErrors = true
     }
     buildFeatures {
+        buildConfig = true
         compose = true
     }
     composeOptions {
@@ -85,6 +86,9 @@ dependencies {
     implementation("app.cash.sqldelight:android-driver:2.0.0")
     implementation("app.cash.sqldelight:coroutines-extensions:2.0.0")
 
+    // crash reporting
+    add("playImplementation", "ch.acra:acra-http:5.11.1")
+
 }
 
 sqldelight {

+ 14 - 0
app/src/fdroid/kotlin/org/sirekanyan/outline/CrashReporter.kt

@@ -0,0 +1,14 @@
+package org.sirekanyan.outline
+
+@Suppress("UNUSED_PARAMETER")
+object CrashReporter {
+
+    fun init(app: App) {
+        // no-op
+    }
+
+    fun handleException(throwable: Throwable) {
+        // no-op
+    }
+
+}

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -5,6 +5,7 @@
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
+        android:name=".App"
         android:allowBackup="false"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="false"

+ 13 - 0
app/src/main/java/org/sirekanyan/outline/App.kt

@@ -0,0 +1,13 @@
+package org.sirekanyan.outline
+
+import android.app.Application
+import android.content.Context
+
+class App : Application() {
+
+    override fun attachBaseContext(base: Context?) {
+        super.attachBaseContext(base)
+        CrashReporter.init(this)
+    }
+
+}

+ 29 - 0
app/src/play/kotlin/org/sirekanyan/outline/CrashReporter.kt

@@ -0,0 +1,29 @@
+package org.sirekanyan.outline
+
+import org.acra.ACRA
+import org.acra.config.CoreConfigurationBuilder
+import org.acra.config.HttpSenderConfigurationBuilder
+import org.acra.sender.HttpSender
+
+object CrashReporter {
+
+    fun init(app: App) {
+        val httpSenderConfig = HttpSenderConfigurationBuilder()
+            .withUri(BuildConfig.ACRA_URI)
+            .withHttpMethod(HttpSender.Method.POST)
+            .withBasicAuthLogin(BuildConfig.ACRA_LOGIN)
+            .withBasicAuthPassword(BuildConfig.ACRA_PASSWORD)
+            .withEnabled(true)
+            .build()
+        val config = CoreConfigurationBuilder()
+            .withBuildConfigClass(BuildConfig::class.java)
+            .withPluginConfigurations(httpSenderConfig)
+            .build()
+        ACRA.init(app, config)
+    }
+
+    fun handleException(throwable: Throwable) {
+        ACRA.errorReporter.handleException(throwable)
+    }
+
+}