Using FirebaseUI For Android – Auth

Firebase is a service by Google which provides you with a secure and powerful backend server. One of the biggest features of Firebase is Authentication. Firebase Authentication provides you with several ways of authentication. Those are: email and password, Facebook, Google, Twitter, Github and anonymous.

If you want to add Firebase Authentication to your app, but you want to design your own sign up UI flow, then check out this post.

FirebaseUI for Authentication provides you with a sign in flow using the latest graphics from from the authentication providers (logos from Google, Facebook etc.)

Implementation is quite simple. You just need to add the dependency to your app and write a few lines of code.


You will need to add this dependency to your app/build.gradle file:

You need to remember to check your Firebase Auth version that your app already has (if you don’t know how to add Firebase to your app, check out this post). Firebase, along side it, needs to have the corresponding Firebase Auth version. This is a table that shows which version of Firebase corresponds with Firebase core version.

Using email and password

The simplest way of showing how to add FirebaseUI Auth  is by using only email and passwords.

Here, first we check if there’s a signed in user from the previous session. If there isn’t, then we start the FirebaseUI intent.

We use startActivityForResult() instead of the regular startActivity() because FirebaseUI return some data that we can use to make our app better.

The authentication flow provides several response codes of which the most common are as follows: ResultCodes.OK if a user is signed in, ResultCodes.CANCELLED if the user manually canceled the sign in, ResultCodes.NO_NETWORK if sign in failed due to a lack of network connectivity, and ResultCodes.UNKNOWN_ERROR for all other errors.