DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
What's in store for DevOps in 2023? Hear from the experts in our "DZone 2023 Preview: DevOps Edition" on Fri, Jan 27!
Save your seat
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Using Firebase Tools in Android Studio for Firebase Auth: Part I

Using Firebase Tools in Android Studio for Firebase Auth: Part I

In this series of posts, Laurence Moroney is going to take you through how you can use some great tools to add Firebase Auth to a new Android project.

Laurence Moroney user avatar by
Laurence Moroney
·
Oct. 07, 16 · Tutorial
Like (5)
Save
Tweet
Share
11.18K Views

Join the DZone community and get the full member experience.

Join For Free

With Android Studio version 2.2, we’ve added some great tools to make getting started with Firebase even easier. In this series of posts, I’m going to step you through how you can use these to add Firebase Auth to a new Android project. This is Part I, where I’ll show you how to get the tools up and running, and how you can begin to connect your app to Firebase, adding all the code prerequisites, and automatically generating a Firebase console project with the tools. In Part II of this series, you’ll then do the coding on your app to get it to use Firebase Auth.

If you’re already somewhat familiar with Android development in Android Studio, you can skip to Step 4.

1. Before You Start:

Before beginning, make sure you have the following:

  • Android Studio 2.2 or later (Instructions on downloading and installing here)
  • Google Repository version 26 or later (Instructions on installing here)

2. Create the App:

Here are the steps for creating a basic app:

  1. Create a new Android project with File->New. Give it a friendly name, and click Next.
  2. On the next screen, you’ll be asked for the form factors. Just accept the default, which should be API 15 for ‘Phone and Tablet’, and everything else unchecked. Click next.
  3. The next screen should ask you to ‘Add Activity to Mobile’. Select ‘Empty activity’ and click Next
  4. You’ll then be asked to name the activity. The default is ‘MainActivity’ with a layout file called ‘activity_main’. Just keep these defaults and click Finish

Android Studio will now create the app for you. This might take a few moments, but once it’s done, your Android Studio’s project explorer will look something like this:

Image title

In Step 1 you specified a name and a package. In my case, I called the app ‘BlogFirebaseSample’, and the domain ‘LaurenceMoroney.com’, so I got the package as shown.

This is a basic, empty, app. Let’s run it in the emulator next.

3. Running in the Emulator

Android Emulators are also known as Android Virtual Devices or AVDs for short. You can configure them using the AVD Manager, which is found under the tools menu:

Image title

This allows you to create, manage and launch emulators for Android. Docs and tutorials are available here.

Once you’ve created an AVD, you can run your app in it using the run menu:

Image title

And you can then pick your AVD and launch it. After a few moments, the emulator will launch and you’ll see your app.

Image title

You’re now ready to add Firebase to your app.

4. Adding Firebase to Your Project

On Android Studio’s ‘Tools’ menu, you’ll see an entry that reads ‘Firebase’.

Image title

Select this, and a Firebase Assistant pane will open to the side of your code editor:

Image title

On this pane, click the arrow beside ‘Authentication’, and you’ll see a step through for ‘Email and Password Authentication’.

Image title

Click on this, and you’ll see the steps. Let’s follow these:

Image title

5. Connecting to Firebase.

Click the ‘Connect to Firebase’ button

Your browser will open with a ‘Request for Permissions’ dialog:

Image title

Click ‘Allow’, and then after a ‘Success!’ screen, you’ll be given a dialog with which to connect to Firebase. You can either create a new Firebase project, or, if you have an existing one, you can select that. For this walkthrough, I’m going to create a new project. The project will default to the same name as I gave my app.

Image title

Once you’ve chosen your name, click ‘Connect to Firebase’. Android studio will take a few moments, after which you should see a notification like this — the project was created and connected locally to module:app.

Image title

6. Configuring Your App for Email Authentication

If you now look at the Firebase pane in your project, you’ll see that Step 1 is completed. It’s time to go to Step 2.

Image title


Click the button that says ‘Add Firebase Authentication to your app’. A dialog will pop up mentioning that it will make some changes to your app. Accept this dialog, and your code will be updated.

Once that’s done, click the link that says ‘Firebase console’ in the text under the button. (See screenshot above). This will take you to the Firebase Console.

Image title

There you’ll need to find your project. In this case, it’s called ‘BlogFirebaseSample’, but your name may differ. Click on the tile for your project. You’ll be taken to an overview page for the project. On the left-hand side of this page, you’ll see a link to ‘Auth’. Click it.

At the top of the screen, you’ll see tabs for ‘Users’, ‘Sign In method’ and ‘Email Templates’. Select ‘Sign In Method’.

Image title

From here you can enable the ‘Email/Password’ sign in provider. There are others that you can do, such as Google, Facebook, and Twitter. But for now, just do Email/Password.

You’re now ready to start coding your app. You’ll do that in Part II!

Android Studio Firebase Android (robot) app

Published at DZone with permission of Laurence Moroney, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Architecture and Code Design, Pt. 2: Polyglot Persistence Insights To Use Today and in the Upcoming Years
  • Memory Debugging: A Deep Level of Insight
  • NEXT.JS 13: Be Dynamic Without Limits
  • How To Create a Stub in 5 Minutes

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: