diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b655b29..fe72a9e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,6 +25,7 @@ jobs: echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV echo "KEYSTORE_BASE64=${{ secrets.KEYSTORE_BASE64 }}" >> $GITHUB_ENV + echo "GOOGLE_SERVICES_JSON_BASE64=${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" >> $GITHUB_ENV echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV - uses: actions/checkout@v4 - name: set up JDK 17 diff --git a/README.md b/README.md index a27b9bc..328bfe4 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ If the app cannot connect to the weather service, it will retry the download eve - Interfaces with [openweathermap.org](https://openweathermap.org) - Uses [karoo-ext](https://github.com/hammerheadnav/karoo-ext) (Apache2-licensed) +## Crashlytics + +This app uses Google Crashlytics for crash reporting to help improve stability and performance. + ## Extension Developers: Headwind Data Type If the user has installed the headwind extension on his karoo, you can stream the headwind data type from other extensions via `karoo-ext`. diff --git a/app/.gitignore b/app/.gitignore index 42afabf..2abde4a 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ -/build \ No newline at end of file +/build +/google-services.json diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0734b56..47fb93f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,6 +5,8 @@ plugins { alias(libs.plugins.jetbrains.kotlin.android) alias(libs.plugins.compose.compiler) kotlin("plugin.serialization") version "2.0.20" + alias(libs.plugins.google.gms.google.services) + alias(libs.plugins.google.firebase.crashlytics) } android { @@ -55,6 +57,24 @@ android { } } +tasks.register("addGoogleServicesJson") { + description = "Adds google-services.json to the project" + group = "build" + + doLast { + val googleServicesJson = System.getenv("GOOGLE_SERVICES_JSON_BASE64") + ?.let { Base64.getDecoder().decode(it) } + ?.let { String(it) } + if (googleServicesJson != null) { + val jsonFile = file("$projectDir/google-services.json") + jsonFile.writeText(googleServicesJson) + println("Added google-services.json to the project") + } else { + println("No GOOGLE_SERVICES_JSON_BASE64 environment variable found, skipping...") + } + } +} + tasks.register("generateManifest") { description = "Generates manifest.json with current version information" group = "build" @@ -85,6 +105,7 @@ tasks.register("generateManifest") { tasks.named("assemble") { dependsOn("generateManifest") + dependsOn("addGoogleServicesJson") } dependencies { @@ -99,4 +120,5 @@ dependencies { implementation(libs.androidx.glance.appwidget) implementation(libs.androidx.glance.appwidget.preview) implementation(libs.androidx.glance.preview) + implementation(libs.firebase.crashlytics) } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index f41eb6b..8f0e3e5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,4 +3,6 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.jetbrains.kotlin.android) apply false alias(libs.plugins.compose.compiler) apply false + alias(libs.plugins.google.gms.google.services) apply false + alias(libs.plugins.google.firebase.crashlytics) apply false } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a1acf5..8ce31f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,11 +11,16 @@ androidxComposeMaterial = "1.3.1" glance = "1.1.1" kotlinxSerializationJson = "1.8.0" mapboxSdkTurf = "7.3.1" +firebaseCrashlytics = "19.4.2" +googleGmsGoogleServices = "4.4.2" +googleFirebaseCrashlytics = "3.0.3" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +google-gms-google-services = { id = "com.google.gms.google-services", version.ref = "googleGmsGoogleServices" } +google-firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "googleFirebaseCrashlytics" } [libraries] androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" } @@ -38,6 +43,7 @@ androidx-glance-appwidget-preview = { group = "androidx.glance", name = "glance- androidx-glance-preview = { group = "androidx.glance", name = "glance-preview", version.ref = "glance" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } mapbox-sdk-turf = { module = "com.mapbox.mapboxsdk:mapbox-sdk-turf", version.ref = "mapboxSdkTurf" } +firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics", version.ref = "firebaseCrashlytics" } [bundles] androidx-lifeycle = ["androidx-lifecycle-runtime-compose", "androidx-lifecycle-viewmodel-compose"]