Переглянути джерело

Replaced acra with crashlytics

Vadik Sirekanyan 2 роки тому
батько
коміт
607e04d9b2

+ 3 - 3
.github/workflows/build.yml

@@ -45,9 +45,9 @@ jobs:
           SIGNING_KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
           SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
           SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
-          ACRA_URI: ${{ secrets.ACRA_URI }}
-          ACRA_LOGIN: ${{ secrets.ACRA_LOGIN }}
-          ACRA_PASSWORD: ${{ secrets.ACRA_PASSWORD }}
+          GOOGLE_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }}
+          GOOGLE_APP_ID: ${{ secrets.GOOGLE_APP_ID }}
+          GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
         run: |
           base64 --decode <<< "$SIGNING_KEYSTORE_BASE64" > app/release.keystore
           ./gradlew assembleRelease bundleRelease

+ 8 - 7
app/build.gradle.kts

@@ -55,9 +55,10 @@ android {
         }
         create("play") {
             dimension = "store"
-            listOf("ACRA_URI", "ACRA_LOGIN", "ACRA_PASSWORD").forEach { key ->
-                buildConfigField("String", key, System.getenv(key)?.let { "\"$it\"" } ?: "null")
-            }
+            resValue("string", "project_id", System.getenv("GOOGLE_PROJECT_ID") ?: "")
+            resValue("string", "google_app_id", System.getenv("GOOGLE_APP_ID") ?: "")
+            resValue("string", "google_api_key", System.getenv("GOOGLE_API_KEY") ?: "")
+            resValue("string", "com.crashlytics.android.build_id", "1")
         }
     }
     compileOptions {
@@ -102,7 +103,7 @@ dependencies {
     implementation("app.cash.sqldelight:coroutines-extensions:2.0.1")
 
     // crash reporting
-    add("playImplementation", "ch.acra:acra-http:5.11.3")
+    add("playImplementation", "com.google.firebase:firebase-crashlytics:18.6.1")
 
 }
 
@@ -128,9 +129,9 @@ androidComponents {
                         add("SIGNING_KEY_PASSWORD")
                     }
                     if (variant.flavorName == "play") {
-                        add("ACRA_URI")
-                        add("ACRA_LOGIN")
-                        add("ACRA_PASSWORD")
+                        add("GOOGLE_PROJECT_ID")
+                        add("GOOGLE_APP_ID")
+                        add("GOOGLE_API_KEY")
                     }
                 }.forEach { key ->
                     if (System.getenv(key).isNullOrEmpty()) {

+ 6 - 0
app/lint.xml

@@ -0,0 +1,6 @@
+<lint>
+    <issue id="UnusedResources">
+        <ignore regexp="`R\.string\.project_id` appears to be unused" />
+        <ignore regexp="`R\.string\.com_crashlytics_android_build_id` appears to be unused" />
+    </issue>
+</lint>

+ 0 - 1
app/proguard.pro

@@ -1,2 +1 @@
 -dontwarn javax.annotation.processing.*
--keep class org.acra.** { *; }

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

@@ -36,8 +36,8 @@ class App : Application() {
     val debugDao: DebugDao by lazy { DebugDaoImpl(database) }
     val res: Res by lazy { ResImpl(this) }
 
-    override fun attachBaseContext(base: Context?) {
-        super.attachBaseContext(base)
+    override fun onCreate() {
+        super.onCreate()
         CrashReporter.init(this)
     }
 

+ 5 - 17
app/src/play/kotlin/org/sirekanyan/outline/CrashReporter.kt

@@ -1,29 +1,17 @@
 package org.sirekanyan.outline
 
-import org.acra.ACRA
-import org.acra.config.CoreConfigurationBuilder
-import org.acra.config.HttpSenderConfigurationBuilder
-import org.acra.sender.HttpSender
+import com.google.firebase.Firebase
+import com.google.firebase.crashlytics.crashlytics
+import com.google.firebase.initialize
 
 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)
+        Firebase.initialize(app)
     }
 
     fun handleException(throwable: Throwable) {
-        ACRA.errorReporter.handleException(throwable)
+        Firebase.crashlytics.recordException(throwable)
     }
 
 }