Android Google Analytics v4 - Installation referrer receiver registration failure

I’m working with Google Analytics v4 in my Android project and having issues with campaign tracking. Everything was working properly for several days, but now I’m getting an error message saying the broadcast receiver isn’t registered.

The error log shows: CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible.

Here’s my manifest configuration inside the application tag:

<service android:name="com.google.android.gms.analytics.CampaignTrackingService"
    android:enabled="true"
    android:exported="false" />
<receiver
    android:name="com.example.app.InstallReferrerReceiver"
    android:exported="true" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

My custom receiver implementation:

public class InstallReferrerReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context ctx, Intent data) {
      
    // Forward to Google Analytics
    new CampaignTrackingReceiver().onReceive(ctx, data);
      
    Log.d("InstallTracker", "Action: " + data.getAction());
    Log.d("InstallTracker", "Data: " + data.getDataString());
    Log.d("InstallTracker", "Intent: " + data.toString());
    Log.d("InstallTracker", "Referrer: " + data.getStringExtra("referrer"));
       
    // Handle other tracking services
  }
}

I only have one INSTALL_REFERRER filter declared in my manifest. Can’t figure out why this stopped working suddenly. Any ideas what might be causing this issue?

This usually happens when multiple dependencies declare their own install referrer receivers. You might only see one receiver in your main manifest, but other libraries can add their own during the build process. Check your merged manifest at app/build/intermediates/merged_manifests/ to identify any duplicate receivers causing conflicts. Additionally, make sure your custom receiver class is in the correct package path as specified in your manifest. ProGuard may also be obfuscating your receiver class in release builds, so consider adding keeping rules if you’re building for release. Since this issue started recently, it’s possible something changed in your build setup or dependencies; check for any recent Gradle updates or library version changes.

Had this exact problem last year when Google deprecated the old install referrer method. The INSTALL_REFERRER broadcast is getting phased out and replaced with the Play Install Referrer API.

Your code looks right for the old method, but Google Play Store isn’t sending those broadcasts reliably anymore. I switched to the new API and haven’t had issues since.

Add this to your build.gradle:

implementation 'com.android.installreferrer:installreferrer:2.2'

Then replace your broadcast receiver with the InstallReferrerClient:

InstallReferrerClient referrerClient = InstallReferrerClient.newBuilder(this).build();
referrerClient.startConnection(new InstallReferrerStateListener() {
    @Override
    public void onInstallReferrerSetupFinished(int responseCode) {
        if (responseCode == InstallReferrerClient.InstallReferrerResponse.OK) {
            ReferrerDetails response = referrerClient.getInstallReferrer();
            String referrerUrl = response.getInstallReferrer();
            // Send to Analytics
        }
    }
});

This API’s way more reliable and works consistently across different Android versions. The broadcast method was always flaky.