85

I am trying to implement google analytics service to android app using the following documentation provided in sdk:

https://developers.google.com/analytics/devguides/collection/android/v4/

I am unable to see any information in the analytics admin site.

While the app is running, I am seeing following debug message

"AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See https://developers.google.com/analytics/devguides/collection/android/v4/ for instructions."

Can you please suggest me how to register this service?

Sergii
  • 1,441
  • 2
  • 24
  • 36
CreativeManix
  • 2,048
  • 1
  • 15
  • 27
  • Check if you have initialized analytics in application class or the primary landing activity too. I recommend removing the global tracker (XML) code. – Manan Sharma Jun 29 '15 at 11:17

4 Answers4

178

I am not sure if acting on this warning will solve the issue you're having (i.e. not seeing any information in the Analytics admin site).

Anyway, here is what you should add to AndroidManifest.xml inside the application tag if you want to get rid of this warning:

 <!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
      dispatching on non-Google Play devices -->
 <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"/>

 <!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
      installation campaign reporting -->
 <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
     android:exported="true">
     <intent-filter>
         <action android:name="com.android.vending.INSTALL_REFERRER" />
     </intent-filter>
 </receiver>
 <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />

You don't have to add all of this, just add what you need. In your case, you apparently just need to add the AnalyticsService service.

Source: https://developer.android.com/reference/com/google/android/gms/analytics/GoogleAnalytics.html

Karim
  • 5,182
  • 2
  • 27
  • 35
  • 9
    I solved this through this method. However, one thing to take note for beginner is that these codes may need to be added inside "application" tag =) – yi2ng2 Aug 17 '15 at 15:15
  • 57
    The real question is why are these not present here : https://developers.google.com/analytics/devguides/collection/android/v4/ ? – Buddy Sep 15 '15 at 15:49
  • 6
    @EnesBattal maybe because these are required only on devices not having Google play services. But I too feel it should be mentioned in those docs. – aandis Sep 16 '15 at 19:13
  • 2
    I added these to my manifest and now I no longer get the warning in LogCat, but when I enable debugging for GoogleAnalytics I still get them in the terminal? The commands I've used to enable debugging in Terminal: "adb shell setprop log.tag.GAv4 DEBUG" and "adb logcat -s GAv4" – Mehlyfication Jan 13 '16 at 11:16
  • @zack, if the app is going to the Play Store, then that means you don't know what device the app will be installed into, therefore, it's implied that these services and receivers must be added to the manifest. Certainly in my case, I have several devices which have the Play services already installed, and this was the only way to get rid of the warnings in LogCat – Phileo99 Mar 03 '16 at 23:02
26

add this on manifest

 <service android:name="com.google.android.gms.analytics.AnalyticsService"
 android:enabled="true"
 android:exported="false"/>
Steve Lai
  • 627
  • 1
  • 6
  • 17
8

Karim explained it well, but it won't work until you give the Wake lock permission in the manifest.

<uses-permission android:name="android.permission.WAKE_LOCK" />

Google v4 dispatch reference.

Community
  • 1
  • 1
Dávid Tímár
  • 679
  • 9
  • 14
0

I had quite similar problem - message about AnalyticsService looks like your device doesn't have Google Services, but it wasn't true for me. However, I've realized that I couldn't be sure that this log'd been invoked from my app - log looked like that: 10173-10192/? V/GAV4, so package name was hidden.

To see logs from Google Analytics, you should change log level to verbose:

GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);

It will help you to analyze, what is a cause of your problems.

Krzysztof Skrzynecki
  • 1,680
  • 19
  • 32