
In short
To add Firebase Analytics to an Android app, create a Firebase project linked to a GA4 property, register the app's package name, put google-services.json in the app module and add the Google services plugin and Firebase BoM to Gradle. Then log custom events with logEvent and check them in DebugView before they reach GA4 reports.
Contents7 sections
Firebase Analytics (Google Analytics for Firebase) sends your app's events to Google Analytics 4, so you can see how people use your Android app and improve it. This step-by-step guide covers creating the Firebase project, registering the app, adding the config file and Gradle setup, logging custom events and testing them in DebugView.
Firebase Analytics works in Android, iOS and web apps. Here we focus on Android.
Step 1: Create a Firebase project
- In the Firebase console, click Add project, then select or enter a project name. If you have an existing Google Cloud project, you can select it from the dropdown to add Firebase resources to that project.
- (Optional) If you are creating a new project, you can edit the project ID. Firebase assigns a unique ID automatically. See Understand Firebase projects for how Firebase uses it.

- Click Continue.

- Choose an existing Google Analytics account or create a new one, choose the GA4 property, then click Create project.
Firebase provisions resources for the project and then opens its overview page in the Firebase console.

Step 2: Register the app with Firebase
- Go to the Firebase console.
- On the project overview page, click the Android icon or Add app to start the setup workflow.
- Enter your app's package name in the Android package name field.
- (Optional) Enter an app nickname and the debug signing certificate SHA-1.
- Click Register app.

Step 3: Add the config file and Gradle setup
- Click Download google-services.json and place the file in your app module (app-level) directory.
- Add the Google services Gradle plugin, which makes the values in google-services.json available to the Firebase SDKs. In your root-level (project-level) Gradle file,
build.gradle.kts:
plugins {
// ...
// Add the dependency for the Google services Gradle plugin
id("com.google.gms.google-services") version "4.5.0" apply false
}
- In your module (app-level) Gradle file, usually
app/build.gradle.kts, apply the plugin:
plugins {
id("com.android.application")
// Add the Google services Gradle plugin
id("com.google.gms.google-services")
}
- In the same module-level file, add the Analytics library. Google recommends the Firebase Android BoM, which keeps your Firebase library versions compatible, so you don't set a version on each library:
dependencies {
// Import the Firebase BoM
implementation(platform("com.google.firebase:firebase-bom:35.1.0"))
// Add the dependency for the Firebase SDK for Google Analytics
implementation("com.google.firebase:firebase-analytics")
// Add the dependencies for any other Firebase products you want to use
}
The version numbers above are current at the time of writing. Check the Firebase Android setup guide for the latest versions and the Groovy syntax if your project uses build.gradle files. Then sync your project in Android Studio.
Step 4: Log custom events
- Once the SDK is added, Firebase starts recording automatically collected events such as
screen_view,first_open,session_start,app_removeandapp_update. See the full list of automatically collected events. - Get a FirebaseAnalytics instance in your activity's
onCreate():mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);in Java, orfirebaseAnalytics = Firebase.analyticsin Kotlin. - Log your own events. In this example, the app logs an event when a user taps the share image option:
Bundle params = new Bundle();
params.putString("screen_name", screenName);
params.putString("image_name", name);
params.putString("full_text", text);
mFirebaseAnalytics.logEvent("share_image", params);
How do you test Firebase events?
Test in two places: the Android Studio log and DebugView.
- Android Studio: with verbose logging enabled, check that the custom event and its parameters appear in Logcat when you perform the action in the app.

- DebugView: enable debug mode on your test device with
adb shell setprop debug.firebase.analytics.app PACKAGE_NAME, then open Analytics > DebugView in the Firebase console. You see events and their parameters in real time, so you can confirm they are recorded correctly and fix any that aren't. Turn debug mode off withadb shell setprop debug.firebase.analytics.app .none.

Where do Firebase events appear in reports?
After processing, your events appear in the Firebase console and in the linked GA4 property's reports.


To use these events as app conversions, mark the important ones as key events in GA4. Our guide to app conversion tracking with GA4 and Firebase covers this.
Summary
To set up Firebase Analytics on Android, create a Firebase project linked to GA4, register your app, add google-services.json and the Gradle plugin and BoM, log custom events with logEvent and test them in DebugView. Firebase then reports your app's events in Firebase and GA4.
Watch the video for this post: youtube.com/embed/8nZTRoU_heY


