In android studio 3.6.1 I used the long way but it worked as shown below:
- Log in to Android Studio 3.6.1 from the to right user icon
- Log in to firebase console with the same account address
- On the firebase console start a new project
In the center of the project overview page, click the Android icon (plat_android) to launch the setup workflow.
5.Enter your app's package name in the Android package name field
- Add the Firebase Android configuration file to your app by:
- Click Download google-services.json to obtain your Firebase Android config file (google-services.json).
Move your config file into the module (app-level) directory of your app.
To enable Firebase products in your app, add the google-services plugin to your Gradle files.
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.
11
`buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}`
11
.In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:
apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
// ...
}
Add Firebase SDKs to your app
To your module (app-level) Gradle file (usually app/build.gradle), add the dependencies for the Firebase products that you want to use in your app.
dependencies {
// ...
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.3.0'
// Add the dependencies for any other Firebase products you want to use in your app
// For example, to also use Firebase Authentication
implementation 'com.google.firebase:firebase-auth:19.3.0'
// Getting a "Could not find" error? Make sure that you've added
// Google's Maven repository to your root-level build.gradle file
}
Sync your app to ensure that all dependencies have the necessary versions.
- If you added Analytics, run your app to send verification to Firebase that you've successfully integrated Firebase. Otherwise, you can skip the verification step.
- Your device logs will display the Firebase verification that initialization is complete. If you ran your app on an emulator that has network access, the Firebase console notifies you that your app connection is complete.