From 7d1e8b5a08583c04b876919af8d2cac39d53e2a0 Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Paz Date: Wed, 20 Aug 2025 16:44:16 -0400 Subject: [PATCH 1/4] [Infra] Improve datastore support Bump the dependency to version 1.1.7 to include the fix in https://developer.android.com/jetpack/androidx/releases/datastore#1.1.5 to mitigate `CorruptionExceptions` Additionally, a corruption handler has been added to the `JavaDataStorage` class. --- .../google/firebase/datastorage/JavaDataStorage.kt | 14 +++++++++++++- gradle/libs.versions.toml | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt b/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt index 9b16720210e..2f3ea6ac1e2 100644 --- a/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt +++ b/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt @@ -17,11 +17,15 @@ package com.google.firebase.datastorage import android.content.Context +import android.os.Process +import android.util.Log import androidx.datastore.core.DataStore +import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler import androidx.datastore.preferences.SharedPreferencesMigration import androidx.datastore.preferences.core.MutablePreferences import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences import androidx.datastore.preferences.preferencesDataStore import com.google.firebase.annotations.concurrent.Background import kotlinx.coroutines.flow.firstOrNull @@ -60,7 +64,15 @@ class JavaDataStorage(val context: Context, val name: String) { private val Context.dataStore: DataStore by preferencesDataStore( name = name, - produceMigrations = { listOf(SharedPreferencesMigration(it, name)) } + produceMigrations = { listOf(SharedPreferencesMigration(it, name)) }, + corruptionHandler = + ReplaceFileCorruptionHandler { ex -> + Log.w( + JavaDataStorage::class.simpleName, + "CorruptionException in ${name} DataStore running in process ${Process.myPid()}" + ) + emptyPreferences() + } ) private val dataStore = context.dataStore diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a634c5f080f..40fc59d2a6f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ constraintlayout = "2.1.4" coreKtx = "1.12.0" coroutines = "1.9.0" dagger = "2.51" # Don't bump above 2.51 as it causes a bug in AppDistro FeedbackSender JPEG code -datastore = "1.1.3" +datastore = "1.1.7" dexmaker = "2.28.1" dexmakerVersion = "1.2" espressoCore = "3.6.1" @@ -238,4 +238,4 @@ spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } protobuf = { id = "com.google.protobuf", version.ref = "protobufGradlePlugin" } errorprone = { id = "net.ltgt.errorprone", version.ref = "gradleErrorpronePlugin" } google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" } -crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" } \ No newline at end of file +crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsGradle" } From 9f55ea1fb45df4d68d41f32e1fde636cc389db59 Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Paz Date: Wed, 20 Aug 2025 16:50:35 -0400 Subject: [PATCH 2/4] Include firebase-sessions bump --- firebase-sessions/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firebase-sessions/CHANGELOG.md b/firebase-sessions/CHANGELOG.md index 1d40247f8f7..49730f25f08 100644 --- a/firebase-sessions/CHANGELOG.md +++ b/firebase-sessions/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased - +* [fixed] Bumped DataStore dependency to include the mitigation for + `CorruptionException` released in version `1.1.5`. See Jetpacks' DataStore + [release notes](https://developer.android.com/jetpack/androidx/releases/datastore#1.1.5). # 3.0.0 * [changed] Added internal api for Crashlytics to notify Sessions of crash events @@ -55,4 +57,3 @@ # 1.0.0 * [feature] Initial Firebase sessions library. - From 549003ae26cb89055907c9ea544b82691703b754 Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Paz Date: Wed, 20 Aug 2025 17:14:53 -0400 Subject: [PATCH 3/4] Include changelog entries for the full library group --- firebase-crashlytics-ndk/CHANGELOG.md | 7 +++---- firebase-crashlytics/CHANGELOG.md | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/firebase-crashlytics-ndk/CHANGELOG.md b/firebase-crashlytics-ndk/CHANGELOG.md index 09b47444a04..0f9763a12f5 100644 --- a/firebase-crashlytics-ndk/CHANGELOG.md +++ b/firebase-crashlytics-ndk/CHANGELOG.md @@ -1,5 +1,5 @@ # Unreleased - +* [changed] Updated `firebase-crashlytics` dependency to 20.0.1 # 20.0.0 * [changed] **Breaking Change**: Updated minSdkVersion to API level 23 or higher. @@ -243,12 +243,12 @@ change. The following release notes describe changes in the new SDK.
  • If you're using [crashlytics] for NDK crash reporting in your app for the first time, follow the getting - started instructions. + started instructions.
  • If you're upgrading from the legacy Fabric SDK to the [firebase_crashlytics] SDK for NDK crash reporting, follow the upgrade - instructions to update your app with the following SDK changes. + instructions to update your app with the following SDK changes.
  • @@ -259,4 +259,3 @@ change. The following release notes describe changes in the new SDK. uploading symbol files to [crashlytics] servers. See the [[crashlytics] Gradle plugin documentation](/docs/crashlytics/ndk-reports-new-sdk) for more information. - diff --git a/firebase-crashlytics/CHANGELOG.md b/firebase-crashlytics/CHANGELOG.md index 9c18c722fe7..1deae6608e4 100644 --- a/firebase-crashlytics/CHANGELOG.md +++ b/firebase-crashlytics/CHANGELOG.md @@ -1,5 +1,5 @@ # Unreleased - +** [changed] Updated `firebase-sessions` dependency to v3.0.1 # 20.0.0 * [changed] **Breaking Change**: Removed deprecated public constructor `KeyValueBuilder(crashlytics: FirebaseCrashlytics)` @@ -683,12 +683,12 @@ The following release notes describe changes in the new SDK.
  • If you're using [crashlytics] for NDK crash reporting in your app for the first time, follow the getting - started instructions. + started instructions.
  • If you're upgrading from the legacy Fabric SDK to the [firebase_crashlytics] SDK, follow the upgrade - instructions to update your app with the following SDK changes. + instructions to update your app with the following SDK changes.
  • @@ -702,4 +702,3 @@ The following release notes describe changes in the new SDK. from your `AndroidManifest.xml` file. * [removed] The `fabric.properties` and `crashlytics.properties` files are no longer supported. Remove them from your app. - From 53795c1c027f400a04828b437e68f968db4340ce Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Date: Wed, 20 Aug 2025 17:15:55 -0400 Subject: [PATCH 4/4] Update firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../java/com/google/firebase/datastorage/JavaDataStorage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt b/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt index 2f3ea6ac1e2..8de2b3bae4b 100644 --- a/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt +++ b/firebase-common/src/main/java/com/google/firebase/datastorage/JavaDataStorage.kt @@ -69,7 +69,8 @@ class JavaDataStorage(val context: Context, val name: String) { ReplaceFileCorruptionHandler { ex -> Log.w( JavaDataStorage::class.simpleName, - "CorruptionException in ${name} DataStore running in process ${Process.myPid()}" + "CorruptionException in ${name} DataStore running in process ${Process.myPid()}", + ex ) emptyPreferences() }