Skip to content

Commit

Permalink
Add Crashlytics (#103)
Browse files Browse the repository at this point in the history
Adds Firebase Crashlytics with the intent to
make it opt-in behavior on the login screen and under settings.
  • Loading branch information
jocmp committed Jun 16, 2024
1 parent 3677985 commit 09004ae
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
local.properties
fastlane/report.xml
app/release/
app/google-services.json
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 30 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
kotlin("plugin.serialization") version libs.versions.kotlin
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
}

android {
Expand Down Expand Up @@ -76,13 +80,13 @@ dependencies {
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.core:core-ktx:1.13.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("androidx.paging:paging-compose:3.2.1")
implementation("androidx.paging:paging-compose:3.3.0")
implementation("androidx.paging:paging-runtime-ktx:$pagingVersion")
implementation("androidx.webkit:webkit:1.10.0")
implementation("androidx.webkit:webkit:1.11.0")
implementation("androidx.work:work-runtime-ktx:2.9.0")
implementation("app.cash.sqldelight:android-driver:$sqldelightVersion")
implementation("io.coil-kt:coil-compose:2.6.0")
Expand All @@ -95,14 +99,33 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.okhttp.client)
implementation(platform("androidx.compose:compose-bom:2024.04.01"))
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
implementation(platform("io.insert-koin:koin-bom:3.5.1"))
implementation(project(":capy"))
implementation("com.google.firebase:firebase-crashlytics:19.0.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.04.01"))
androidTestImplementation(platform("androidx.compose:compose-bom:2024.06.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}

tasks.register("useGoogleServicesDebugFile") {
description = "Copies the debug google-services.json file if file is missing."
doLast {
val googleServicesFile = "google-services.json"
if (!file("${project.projectDir}/$googleServicesFile").exists()) {
val debugOnlyFile = "google-services-debug-only.json"
println("$googleServicesFile file is missing. Copying $debugOnlyFile")
copy {
from("${project.projectDir}/$debugOnlyFile")
into(project.projectDir)
rename { googleServicesFile }
}
}
}
}

project.tasks.preBuild.dependsOn("useGoogleServicesDebugFile")
29 changes: 29 additions & 0 deletions app/google-services-debug-only.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "274059433914",
"project_id": "capy-reader-debug",
"storage_bucket": "capy-reader-debug.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:274059433914:android:2c1d21f3a0f12546c52f83",
"android_client_info": {
"package_name": "com.jocmp.capyreader"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAuMQpqtiSry6g2ecznF7cdCWgkxYN3nW8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
android:theme="@style/Theme.CapyReader"
android:enableOnBackInvokedCallback="true"
tools:targetApi="33">
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down Expand Up @@ -46,5 +49,4 @@
tools:node="remove" />
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.autofill.AutofillType.EmailAddress
import androidx.compose.ui.autofill.AutofillType.Password
import androidx.compose.ui.tooling.preview.Preview
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.jocmp.capyreader.ui.autofill
import org.koin.compose.koinInject

Expand Down Expand Up @@ -63,6 +66,10 @@ fun LoginScreen(
Text("Save")
}
}

LaunchedEffect(Unit) {
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}
}

@Preview
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ plugins {
id("org.jetbrains.kotlin.jvm") version libs.versions.kotlin apply false
id("com.android.library") version "8.3.1" apply false
id("org.jetbrains.kotlin.plugin.serialization") version libs.versions.kotlin
id("com.google.gms.google-services") version "4.4.2" apply false
id("com.google.firebase.crashlytics") version "3.0.1" apply false
}
6 changes: 3 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
mavenCentral()
google()
}
}

Expand All @@ -21,7 +21,7 @@ dependencyResolutionManagement {
version("kotlin", "1.9.22")
version("sqldelight", "2.0.1")
version("ksp", "1.9.22-1.0.16")
version("androidx-paging", "3.2.1")
version("androidx-paging", "3.3.0")
library("moshi", "com.squareup.moshi:moshi:1.15.1")
library("okhttp-client", "com.squareup.okhttp3:okhttp:4.12.0")
library("moshi-kotlin-codegen", "com.squareup.moshi:moshi-kotlin-codegen:1.14.0")
Expand Down

0 comments on commit 09004ae

Please sign in to comment.