Skip to content

Commit

Permalink
Replaced acra with crashlytics
Browse files Browse the repository at this point in the history
  • Loading branch information
sirekanian committed Feb 3, 2024
1 parent 165b797 commit 607e04d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")

}

Expand All @@ -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()) {
Expand Down
6 changes: 6 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -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>
1 change: 0 additions & 1 deletion app/proguard.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
-dontwarn javax.annotation.processing.*
-keep class org.acra.** { *; }
4 changes: 2 additions & 2 deletions app/src/main/java/org/sirekanyan/outline/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
22 changes: 5 additions & 17 deletions app/src/play/kotlin/org/sirekanyan/outline/CrashReporter.kt
Original file line number Diff line number Diff line change
@@ -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)
}

}

0 comments on commit 607e04d

Please sign in to comment.