diff --git a/app/build.gradle b/app/build.gradle index 3bfe651d46..0cb45bc695 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,8 @@ android { // Google Play specific configuration dimension "store" isDefault true + apply plugin: 'com.google.gms.google-services' + apply plugin: 'com.google.firebase.crashlytics' } } diff --git a/app/src/google/java/ani/dantotsu/connections/crashlytics/FirebaseCrashlytics.kt b/app/src/google/java/ani/dantotsu/connections/crashlytics/FirebaseCrashlytics.kt index c305f1b879..64ab524ffe 100644 --- a/app/src/google/java/ani/dantotsu/connections/crashlytics/FirebaseCrashlytics.kt +++ b/app/src/google/java/ani/dantotsu/connections/crashlytics/FirebaseCrashlytics.kt @@ -1,10 +1,16 @@ package ani.dantotsu.connections.crashlytics +import android.content.Context +import com.google.firebase.FirebaseApp import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.ktx.crashlytics import com.google.firebase.ktx.Firebase +import com.google.firebase.ktx.app class FirebaseCrashlytics : CrashlyticsInterface { + override fun initialize(context: Context) { + FirebaseApp.initializeApp(context) + } override fun logException(e: Throwable) { FirebaseCrashlytics.getInstance().recordException(e) } diff --git a/app/src/main/java/ani/dantotsu/App.kt b/app/src/main/java/ani/dantotsu/App.kt index 91500e4ca5..5c11e74f75 100644 --- a/app/src/main/java/ani/dantotsu/App.kt +++ b/app/src/main/java/ani/dantotsu/App.kt @@ -57,6 +57,7 @@ class App : MultiDexApplication() { Injekt.importModule(PreferenceModule(this)) val crashlytics = Injekt.get() + crashlytics.initialize(this) val useMaterialYou: Boolean = PrefManager.getVal(PrefName.UseMaterialYou) if (useMaterialYou) { diff --git a/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsInterface.kt b/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsInterface.kt index 52752b4e8a..54307d245c 100644 --- a/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsInterface.kt +++ b/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsInterface.kt @@ -1,6 +1,9 @@ package ani.dantotsu.connections.crashlytics +import android.content.Context + interface CrashlyticsInterface { + fun initialize(context: Context) fun logException(e: Throwable) fun log(message: String) fun setUserId(id: String) diff --git a/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsStub.kt b/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsStub.kt index 2e6b255a69..524d42bf51 100644 --- a/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsStub.kt +++ b/app/src/main/java/ani/dantotsu/connections/crashlytics/CrashlyticsStub.kt @@ -1,6 +1,11 @@ package ani.dantotsu.connections.crashlytics +import android.content.Context + class CrashlyticsStub : CrashlyticsInterface { + override fun initialize(context: Context) { + //no-op + } override fun logException(e: Throwable) { //no-op } diff --git a/build.gradle b/build.gradle index bd012c8fd1..2aa991c52a 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,9 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "com.google.devtools.ksp:symbol-processing-api:$ksp_version" classpath "com.google.devtools.ksp:symbol-processing-gradle-plugin:$ksp_version" + + classpath 'com.google.gms:google-services:4.4.0' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' } }