AnalyticsService not registered in the app manifest - error

前端 未结 4 655
小鲜肉
小鲜肉 2020-11-29 20:43

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

https://developers.google.com/analytics/devguides

相关标签:
4条回答
  • 2020-11-29 21:26

    add this on manifest

     <service android:name="com.google.android.gms.analytics.AnalyticsService"
     android:enabled="true"
     android:exported="false"/>
    
    0 讨论(0)
  • 2020-11-29 21:28

    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

    0 讨论(0)
  • 2020-11-29 21:31

    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.

    0 讨论(0)
  • 2020-11-29 21:38

    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.

    0 讨论(0)
提交回复
热议问题