Integrate Android uninstall measurement into an app

At a glance: Set up uninstall measurement in Android apps by integrating Firebase Cloud Messaging into the app.

Related reading: Principles of uninstall measurement

Android uninstall measurement

Android uninstall measurement is available by configuring uninstall measurement in AppsFlyer and adopting Firebase Cloud Messaging (FCM) into your app. Starting April 2021, AppsFlyer supports both the FCM legacy API and HTTP V1 API. FCM encourages the adoption of the V1 version

Uninstall measurement implementation checklist 
Step Action Responsibility
1 Connect FCM to AppsFlyer

Select an integration API:


Integrate FCM into the app

The integration differs if you use FCM only with AppsFlyer or you use it with multiple platforms.

  1. Adopt FCM into the app.
  2. Do one of the following:
  3. [Optional] If you use Proguard, complete Enabling Proguard.
3 Test uninstall measurement Developer

Connect FCM API to AppsFlyer

Select an FCM API version [Best practice] HTTP V1 or legacy HTTP. 


To configure FCM API V1 for uninstalls: 

  1. To get the Project ID:
    1. Go to the FCM console.
    2. Select a project. 
    3. Go to Project Overview > Project settings.


    4. Copy the Project ID. You will need it at a later stage in the process. 
  2. To assign AppsFlyer the uninstall role:
    1. Go to the Service accounts tab. 
    2. Click Manage service account permissions
      A new browser tab opens in Google Cloud Platform.
    3. In the side menu, select Roles
    4. Click +Create role.
    5. Complete as follows:
      • Title: Enter AppsFlyer uninstalls.
      • ID: Enter af_uninstalls
      • Role launch stage: Select General availability
    6. Search and then select cloudmessaging.messages.create.


    7. Click Add.
    8. Click Create
  3. To assign AppsFlyer the FCM uninstall role:
    1. In the side menu, select IAM.
    2. Click + Add.
    3. In the New members field insert
    4. Select a role, select AppsFlyer uninstalls.
    5. Click Save
      The AppsFlyer service account has been assigned the role of AppsFlyer uninstalls. 
  4. To enable uninstall measurement in AppsFlyer:
    1. In AppsFlyer, go to Configuration > App Settings.
    2. If necessary, turn on Uninstall measurement
    3. Select HTTP V1.


    4. Enter the Project ID you prepared earlier in this section.
    5. Click Test connection.
      The Success! message displays. 
    6. Click Save settings

Legacy HTTP

Uninstall measurement using Firebase Messaging is supported by Android SDK V4.7.0+

  1. To obtain the Firebase server key:
    1. Create a Firebase Android Application project (if you have not already done so), or migrate your project from Google Developer Console (follow the instructions there). For more information, go to Firebase
    2. Open the Firebase Console.
    3. In the Firebase Console, navigate to the Project Settings (click on the cogwheel next to Project Overview on the left pane of the page).


    4. In the Cloud Messaging tab, you see two Server Keys.
    5. Copy the Server Key.
  2. To enable uninstall measurement in AppsFlyer:
    1. In AppsFlyer, go to Configuration > App Settings.
    2. If necessary, turn on Uninstall measurement
    3. Select Legacy HTTP.
    4. Enter the Firebase/GCM Server Key you prepared in the previous step.
    5. Click Save settings

Integrate FCM into the app

Use the following procedures (as needed) to integrate FCM into the app and test the integration.

Adopt FCM into the app

  • The latest Firebase version can be found here: Firebase official doc.
  • If you receive a "Could not find.." error, make sure you have the latest Google Repository in the Android SDK Manager.
To adopt FCM in your app:
  1. Download google-services.json from Firebase console.
  2. Add the google-services.json to the app module directory,
  3. Add rules to your root-level build.gradle file, to include the google-services plugin:
    buildscript { 
        // ... 
        dependencies { 
          // ... 
          classpath '' // google-services plugin 
  4. Add the FCM dependency to your app-level build.gradle file:

    dependencies {
       implementation ''
    apply plugin: '

Use FCM with the AppsFlyer SDK only

If the sole purpose of integrating FCM is to measure uninstalls in AppsFlyer, use  appsFlyer.FirebaseMessagingServiceListener service, embedded in the SDK. This extends the FirebaseFirebaseMessagingService class, used to receive the FCM Device Token.

To add appsFlyer.FirebaseMessagingServiceListener service to the app:

   <!-- ... -->
          <action android:name=""/>
   <!-- ... -->

Use FCM with multiple platforms

If you intend to use FCM with more than one platform, SDK, or both, you must implement logic that collects the Device Token and passes it to all relevant platforms. To do by extending a new instance of the FirebaseMessagingService (similar to the service the AppsFlyer SDK extends):
import com.appsflyer.AppsFlyerLib;

public class MyNewFirebaseManager extends FirebaseMessagingService {

    public void onNewToken(String s) {

        // Sending new token to AppsFlyer
       	       AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), s);

        // the rest of the code that makes use of the token goes in this method as well
That service should be added to AndroidManifest.xml in order to function: If the application used FCM before integrating the AppsFlyer SDK, it is likely that the service is extended and the developer needs to add the following to the onNewToken() method:
AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), refreshedToken); 

Verify that have added the relevant service to the AndroidManifest.xml.

        <action android:name="" />

Using Proguard with uninstall measurement

If you use Proguard, add the following rule:

-dontwarn com.appsflyer.**
-keep public class {
  public *;

Test Android uninstall measurement

  • The testing procedure described is valid for apps available via Google Play Store, pending, direct download, and via alternative app stores. 
  • The Uninstalls metric is available in the Overview dashboard.
  • The list of users who uninstall the app is available in the uninstalls raw-data report.

To test Android uninstall measurement:

  1. Install the app.
  2. Uninstall the app.  Note! You can uninstall the app immediately after installing it.
    The uninstall event registers within 24 hours as uninstall measurement is processed daily.
    If the app is reinstalled during this time -
    no uninstall event is recorded.

The app uninstall event takes up to 48 hours to display in raw-data reports and in the Aggregated Performance Report in your AppsFlyer dashboard.


Other information

Solving Android uninstall push notification not being silent

Overriding FCMs onMessageReceived method and implementing your own logic in it might cause uninstall push notifications to not be silent. This can impact the user experience. To prevent this, verify that the message contains af-uinstall-tracking. See the following example:

    public void onMessageReceived(RemoteMessage remoteMessage) {
        } else {
           // handleNotification(remoteMessage);
Was this article helpful?