Aman Sharma
Aman Sharma

Reputation: 21

FirebaseAuth signout crashes

My android application crashes when i call signout upon the fitebaseauth instance, below is the logout call...

logout.setOnClickListener {
            logoutAlertDialog.dismiss()
            binding.msgLl.isVisible = true
            binding.msgTv.isVisible = true
            binding.msgTv.text = "Logging out"
            binding.progressBar.isVisible = true

            Handler(Looper.getMainLooper()).postDelayed({
                FirebaseAuth.getInstance().signOut()
                requireContext().startActivity(Intent(requireContext(),MainActivity::class.java))
                requireActivity().finish()
            },3000)

this is the code and

2022-07-13 13:17:50.446 5496-5496/com.aman.ache D/FirebaseAuth: Notifying id token listeners about a sign-out event. 2022-07-13 13:17:50.447 5496-5496/com.aman.ache D/FirebaseAuth: Notifying auth state listeners about a sign-out event.

2022-07-13 13:17:50.452 5496-5496/com.aman.ache E/Parcel: Reading a NULL string not supported here. 2022-07-13 13:17:50.502 5496-6482/com.aman.ache E/libEGL: Invalid file path for libcolorx-loader.so

2022-07-13 13:28:16.702 13149-13529/com.aman.ache W/Firestore: (23.0.3) [Firestore]: Listen for Query(target=Query(Users/GBVFmnu3zPTooz9nvmX6nBaQ6d02 order by name);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

highlighted part is the error in red.

Upvotes: 1

Views: 327

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599696

From the error message it seems like you have an active listener on Firestore for which your security rules require that a user is signed in. When the user signs out that condition is no longer met, so the security rules remove the listener at that point, and raise an error to the SDK which you then log.

You didn't share the code of how you listen for data in Firestore, but you generally have two options:

  • Remove the listener in your application code before you sign the user out.
  • Change your code to ignore the error that you get.

The net result is the same, as the listener also is removed by the system automatically. I typically prefer the first approach though, as it's cleaner to have the application code clean up after itself.

Upvotes: 1

Related Questions