Search code examples
androidgoogle-analyticsandroid-manifestandroid-broadcastreceivergoogle-analytics-sdk

AnalyticsReceiver - what is that for? And why it causes 'Receiver does not require permission' warning?


In my Android application in manifest file i have following receiver and service declaration:

<receiver
   android:name="com.google.android.gms.analytics.AnalyticsReceiver"
   android:enabled="true">
   <intent-filter>
      <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
   </intent-filter>
</receiver>
<service
   android:name="com.google.android.gms.analytics.AnalyticsService"
   android:enabled="true"
   android:exported="false" />

To be honest it's quite old app and I don't remember why I've put that there. It was probably taken from Google Analytics docs. But now I can't find any up-to-date information about it.

What is more Android Studio shows me warning with that receiver:

Receiver does not require permission

Exported receivers (receivers which either set exported=true or contain an intent-filter and do not specify exported=false) should define a permission that an entity must have in order to launch the receiver or bind to it. Without this, any application can use this receiver.

Do I really need that receiver and service in my code? What is this responsible for? Is it still actual?


Solution

  • If you are using the latest version of Google Analytics, no, you do not need to manually specify the service and receiver in your manifest file.

    Here is the Google Analytics getting start guide for Android. Note that if you are upgrading from a significantly older version, you may have additional work to perform elsewhere to upgrade. You should read through the entire guide to ensure that your app is still configured properly.