firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 575 forks source link

com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline. #5928

Closed nazim-baya closed 3 weeks ago

nazim-baya commented 5 months ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

Steps to reproduce:

Just trying to retrieve Firestore data when the user is authenticated and got an offline error Failed to get document because the client is offline.

(25.0.0) [WatchStream]: (df00582) Stream closed with status: Status{code=PERMISSION_DENIED, description=The project was disabled or deleted., cause=null}.
2024-05-03 15:34:25.874  4271-4683  Firestore               com******              W  (25.0.0) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=PERMISSION_DENIED, description=The project was disabled or deleted., cause=null}
                                                                                                    This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
2024-05-03 15:34:25.881  4271-4271  System.err              com******              W  com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline.
2024-05-03 15:34:25.882  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference.lambda$getViaSnapshotListener$1(DocumentReference.java:331)
2024-05-03 15:34:25.882  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda2.onEvent(D8$$SyntheticClass:0)
2024-05-03 15:34:25.882  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2$com-google-firebase-firestore-DocumentReference(DocumentReference.java:526)
2024-05-03 15:34:25.882  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda1.onEvent(D8$$SyntheticClass:0)
2024-05-03 15:34:25.882  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0$com-google-firebase-firestore-core-AsyncEventListener(AsyncEventListener.java:42)
2024-05-03 15:34:25.883  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
2024-05-03 15:34:25.883  4271-4271  System.err              com******              W    at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(D8$$SyntheticClass:0)
2024-05-03 15:34:25.883  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener.onEvent(AsyncEventListener.java:39)
2024-05-03 15:34:25.883  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.QueryListener.raiseInitialEvent(QueryListener.java:196)
2024-05-03 15:34:25.883  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.QueryListener.onOnlineStateChanged(QueryListener.java:127)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.EventManager.handleOnlineStateChange(EventManager.java:259)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.SyncEngine.handleOnlineStateChange(SyncEngine.java:422)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleOnlineStateChange(MemoryComponentProvider.java:145)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore$$ExternalSyntheticLambda1.handleOnlineStateChange(D8$$SyntheticClass:0)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.OnlineStateTracker.setAndBroadcastState(OnlineStateTracker.java:181)
2024-05-03 15:34:25.884  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.OnlineStateTracker.handleWatchStreamFailure(OnlineStateTracker.java:154)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore.handleWatchStreamClose(RemoteStore.java:509)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore.access$200(RemoteStore.java:60)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore$1.onClose(RemoteStore.java:188)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream.close(AbstractStream.java:356)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream.handleServerClose(AbstractStream.java:410)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onClose$3$com-google-firebase-firestore-remote-AbstractStream$StreamObserver(AbstractStream.java:151)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$ExternalSyntheticLambda3.run(D8$$SyntheticClass:0)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onClose(AbstractStream.java:137)
2024-05-03 15:34:25.885  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.FirestoreChannel$1.onClose(FirestoreChannel.java:151)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:463)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:427)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:460)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
2024-05-03 15:34:25.886  4271-4271  System.err              com******              W    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W    at java.lang.Thread.run(Thread.java:1012)
2024-05-03 15:34:25.887  4271-4271  System.err              com******              W  com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline.
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference.lambda$getViaSnapshotListener$1(DocumentReference.java:331)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda2.onEvent(D8$$SyntheticClass:0)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2$com-google-firebase-firestore-DocumentReference(DocumentReference.java:526)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda1.onEvent(D8$$SyntheticClass:0)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0$com-google-firebase-firestore-core-AsyncEventListener(AsyncEventListener.java:42)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(D8$$SyntheticClass:0)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.AsyncEventListener.onEvent(AsyncEventListener.java:39)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.QueryListener.raiseInitialEvent(QueryListener.java:196)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.QueryListener.onOnlineStateChanged(QueryListener.java:127)
2024-05-03 15:34:25.888  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.EventManager.handleOnlineStateChange(EventManager.java:259)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.SyncEngine.handleOnlineStateChange(SyncEngine.java:422)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleOnlineStateChange(MemoryComponentProvider.java:145)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore$$ExternalSyntheticLambda1.handleOnlineStateChange(D8$$SyntheticClass:0)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.OnlineStateTracker.setAndBroadcastState(OnlineStateTracker.java:181)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.OnlineStateTracker.handleWatchStreamFailure(OnlineStateTracker.java:154)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore.handleWatchStreamClose(RemoteStore.java:509)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore.access$200(RemoteStore.java:60)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.RemoteStore$1.onClose(RemoteStore.java:188)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream.close(AbstractStream.java:356)
2024-05-03 15:34:25.889  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream.handleServerClose(AbstractStream.java:410)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onClose$3$com-google-firebase-firestore-remote-AbstractStream$StreamObserver(AbstractStream.java:151)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$ExternalSyntheticLambda3.run(D8$$SyntheticClass:0)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onClose(AbstractStream.java:137)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at com.google.firebase.firestore.remote.FirestoreChannel$1.onClose(FirestoreChannel.java:151)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:463)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:427)
2024-05-03 15:34:25.890  4271-4271  System.err              com******              W    at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:460)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
2024-05-03 15:34:25.891  4271-4271  System.err              com******              W    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
2024-05-03 15:34:25.892  4271-4271  System.err              com******              W    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
2024-05-03 15:34:25.892  4271-4271  System.err              com******              W    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2024-05-03 15:34:25.892  4271-4271  System.err              com******              W    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
2024-05-03 15:34:25.892  4271-4271  System.err              com******              W    at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
2024-05-03 15:34:25.892  4271-4271  System.err              com******              W    at java.lang.Thread.run(Thread.java:1012)
2024-05-03 15:34:26.983  4271-4271  AndroidRuntime          com******              E  FATAL EXCEPTION: main
                                                                                                    Process: com******, PID: 4271
                                                                                                    com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline.
                                                                                                        at com.google.firebase.firestore.DocumentReference.lambda$getViaSnapshotListener$1(DocumentReference.java:331)
                                                                                                        at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda2.onEvent(D8$$SyntheticClass:0)
                                                                                                        at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2$com-google-firebase-firestore-DocumentReference(DocumentReference.java:526)
                                                                                                        at com.google.firebase.firestore.DocumentReference$$ExternalSyntheticLambda1.onEvent(D8$$SyntheticClass:0)
                                                                                                        at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0$com-google-firebase-firestore-core-AsyncEventListener(AsyncEventListener.java:42)
                                                                                                        at com.google.firebase.firestore.core.AsyncEventListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                                                                                                        at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(D8$$SyntheticClass:0)
                                                                                                        at com.google.firebase.firestore.core.AsyncEventListener.onEvent(AsyncEventListener.java:39)
                                                                                                        at com.google.firebase.firestore.core.QueryListener.raiseInitialEvent(QueryListener.java:196)
                                                                                                        at com.google.firebase.firestore.core.QueryListener.onOnlineStateChanged(QueryListener.java:127)
                                                                                                        at com.google.firebase.firestore.core.EventManager.handleOnlineStateChange(EventManager.java:259)
                                                                                                        at com.google.firebase.firestore.core.SyncEngine.handleOnlineStateChange(SyncEngine.java:422)
                                                                                                        at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleOnlineStateChange(MemoryComponentProvider.java:145)
                                                                                                        at com.google.firebase.firestore.remote.RemoteStore$$ExternalSyntheticLambda1.handleOnlineStateChange(D8$$SyntheticClass:0)
                                                                                                        at com.google.firebase.firestore.remote.OnlineStateTracker.setAndBroadcastState(OnlineStateTracker.java:181)
                                                                                                        at com.google.firebase.firestore.remote.OnlineStateTracker.handleWatchStreamFailure(OnlineStateTracker.java:154)
                                                                                                        at com.google.firebase.firestore.remote.RemoteStore.handleWatchStreamClose(RemoteStore.java:509)
                                                                                                        at com.google.firebase.firestore.remote.RemoteStore.access$200(RemoteStore.java:60)
                                                                                                        at com.google.firebase.firestore.remote.RemoteStore$1.onClose(RemoteStore.java:188)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream.close(AbstractStream.java:356)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream.handleServerClose(AbstractStream.java:410)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onClose$3$com-google-firebase-firestore-remote-AbstractStream$StreamObserver(AbstractStream.java:151)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver$$ExternalSyntheticLambda3.run(D8$$SyntheticClass:0)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
                                                                                                        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onClose(AbstractStream.java:137)
                                                                                                        at com.google.firebase.firestore.remote.FirestoreChannel$1.onClose(FirestoreChannel.java:151)
                                                                                                        at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:463)
                                                                                                        at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:427)
                                                                                                        at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:460)
                                                                                                        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
                                                                                                        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
                                                                                                        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
                                                                                                        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
                                                                                                        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
                                                                                                        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
                                                                                                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
                                                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
2024-05-03 15:34:26.983  4271-4271  AndroidRuntime          com******              E    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3a263ba, Dispatchers.Main.immediate]
2024-05-03 15:34:26.999  4271-4271  Process                 com******              I  Sending signal. PID: 4271 SIG: 9

Relevant Code:

Code to retrieve objects in the database :

    private fun createOrUpdateUserInFirestore(user: FirebaseUser?, isSignIn: Boolean) {
        user?.let {
            val db = FirebaseFirestore.getInstance()
            val usersCollection = db.collection("users")

            // Vérifier si l'utilisateur existe déjà
            val userDocument = usersCollection.document(user.uid)
            userDocument.get().addOnSuccessListener { documentSnapshot ->
                val isFirstLogin = !documentSnapshot.exists()

                val userData = mutableMapOf<String, Any?>(
                    "username" to user.displayName,
                    "userEmail" to user.email,
                    "userPhone" to user.phoneNumber,
                    "profilePictureUrl" to user.photoUrl?.toString()
                    // Ajoutez d'autres champs si nécessaire
                )

                if (isSignIn) {
                    if (isFirstLogin) {
                        // C'est la première connexion, définir les valeurs spécifiques
                        userData["subscriptionStartDate"] = null
                        userData["type"] = false
                        userData["amount"] = null
                    }
                }

                // Créez ou mettez à jour l'utilisateur dans la collection Firestore
                userDocument.set(userData, SetOptions.merge())
                    .addOnSuccessListener {
                        // Gestion du succès
                        Log.d("yes", "Utilisateur ajouté ou mis à jour dans Firestore.")
                    }
                    .addOnFailureListener { e ->
                        // Gestion de l'échec
                        Log.e("no", "Erreur lors de l'ajout ou de la mise à jour de l'utilisateur dans Firestore.", e)
                    }
            }
        }
    }

Gradle file :

 implementation(platform("com.google.firebase:firebase-bom:33.0.0"))
    implementation("com.google.firebase:firebase-firestore")
    implementation 'com.google.firebase:firebase-functions'
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0"
    implementation 'com.google.firebase:firebase-firestore-ktx:25.0.0'
    implementation 'com.google.firebase:firebase-storage:21.0.0'
    implementation 'com.google.firebase:firebase-messaging:24.0.0'
    implementation("com.google.firebase:firebase-crashlytics")
    implementation("com.google.firebase:firebase-analytics")

    implementation("com.google.firebase:firebase-appcheck-playintegrity")
`The problem occurred after the May 1st security update for Android: One UI: 6.0 Android: 14 version: G998BXXSAFXCL. Any solution ?? Merci `
google-oss-bot commented 5 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

ehsannas commented 5 months ago

Hi @nazim-baya . I see the following in the log:

(25.0.0) [WatchStream]: (df00582) Stream closed with status: Status{code=PERMISSION_DENIED, description=The project was disabled or deleted., cause=null}.

This suggests that the server sent a PERMISSION_DENIED error to the client before the device went offline. This might be because authentication was not successful, or your Firestore Security Rules blocked the request. As a result, it is unlikely that the local cache will contain anything for when you're offline.

nubpro commented 3 weeks ago

addOnFailureListener

hi

Hi @nazim-baya . I see the following in the log:

(25.0.0) [WatchStream]: (df00582) Stream closed with status: Status{code=PERMISSION_DENIED, description=The project was disabled or deleted., cause=null}.

This suggests that the server sent a PERMISSION_DENIED error to the client before the device went offline. This might be because authentication was not successful, or your Firestore Security Rules blocked the request. As a result, it is unlikely that the local cache will contain anything for when you're offline.

hi, if we do not add addOnFailureListener , will it cause the client app to crash? Because that's what Im experiencing currently

ehsannas commented 3 weeks ago

Yes. If you are offline and try to get a document, if the client is not able to reach the server, it will try to return a document from the cache, and if the document does not exist in the cache either, the SDK will return a Task that has an exception upon completion to indicate the error.