AnalyticsService未在应用清单中注册 - 错误

时间:2022-03-26 14:41:14

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

我正在尝试使用sdk中提供的以下文档将Android分析服务实施到Android应用程序:

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

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."

“AnalyticsService未在应用清单中注册。可能无法可靠地提供匹配。有关说明,请参阅https://developers.google.com/analytics/devguides/collection/android/v4/。”

Can you please suggest me how to register this service?

你能建议我如何注册这项服务吗?

4 个解决方案

#1


176  

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).

我不确定采取此警告是否可以解决您遇到的问题(即没有在Analytics管理网站上看到任何信息)。

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

无论如何,如果你想摆脱这个警告,你应该在应用程序标签内添加AndroidManifest.xml:

 <!-- 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.

您不必添加所有这些,只需添加所需内容即可。在您的情况下,您显然只需要添加AnalyticsService服务。

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

资料来源:https://developer.android.com/reference/com/google/android/gms/analytics/GoogleAnalytics.html

#2


26  

add this on manifest

在清单上添加此项

 <service android:name="com.google.android.gms.analytics.AnalyticsService"
 android:enabled="true"
 android:exported="false"/>

#3


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.

谷歌v4调度参考。

#4


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.

我有类似的问题 - 关于AnalyticsService的消息看起来你的设备没有Google服务,但对我来说并非如此。但是,我意识到我不能确定这个日志是从我的应用程序调用的 - 日志看起来像那样:10173-10192 /? V / GAV4,所以包名被隐藏了。

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

要查看Google Analytics中的日志,您应该将日志级别更改为详细信息:

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

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

它将帮助您分析,问题的原因是什么。

#1


176  

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).

我不确定采取此警告是否可以解决您遇到的问题(即没有在Analytics管理网站上看到任何信息)。

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

无论如何,如果你想摆脱这个警告,你应该在应用程序标签内添加AndroidManifest.xml:

 <!-- 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.

您不必添加所有这些,只需添加所需内容即可。在您的情况下,您显然只需要添加AnalyticsService服务。

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

资料来源:https://developer.android.com/reference/com/google/android/gms/analytics/GoogleAnalytics.html

#2


26  

add this on manifest

在清单上添加此项

 <service android:name="com.google.android.gms.analytics.AnalyticsService"
 android:enabled="true"
 android:exported="false"/>

#3


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.

谷歌v4调度参考。

#4


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.

我有类似的问题 - 关于AnalyticsService的消息看起来你的设备没有Google服务,但对我来说并非如此。但是,我意识到我不能确定这个日志是从我的应用程序调用的 - 日志看起来像那样:10173-10192 /? V / GAV4,所以包名被隐藏了。

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

要查看Google Analytics中的日志,您应该将日志级别更改为详细信息:

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

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

它将帮助您分析,问题的原因是什么。