Mastering Firebase for Android Development
上QQ阅读APP看书,第一时间看更新

Configuring Firebase in Android projects

There are two ways that you can connect Firebase to your Android project, from the Firebase console creating the new project and adding the dependencies and Google config file. The other way is just to add Firebase support to an Android project directly from Android Studio:

  1. The usual way of connecting Firebase is to visit the Firebase console at https://console.firebase.google.com/
  2. Create a new project using the Add Project button, and if you already have an existing project, you are free to choose it
  3. In the overview section of the console, you can choose to add an Android application by clicking on the relevant button and add the necessary information to the fields
  4. Download the google-services.json file, add it to your project's app folder root, and the classpath gradle dependencies in the project's gradle file
  5. To reduce the effort, we can make Android Studio do all this for us by choosing the Tools Firebase menu option and clicking on the Firebase tools that you want to integrate from the list
  6. After you chose the Firebase tool, tap on Save and retrieve data
  7. In the next window panel, you will see options such as Launch in the browserConnect your app to Firebase, and so on, click on the Connect your app to Firebase button and select your project or you can create the new project in the Connect to Firebase window
  8. Go back to the Firebase panel and click on the Add the Realtime Database to your application button

Since we have connected to Firebase, it is as simple as it sounds, all we have to do is select the Add the Realtime Database to your application button in the Firebase assistance window, you will see a dialog for requesting your authorization to change the gradle file with a few dependencies. Tap on Accept Changes, now we are all set to explore Realtime Database abilities.