简体   繁体   English

android google analytics v3:“服务不可用”

[英]android google analytics v3: “Service unavailable”

following the simple guide here, https://developers.google.com/analytics/devguides/collection/android/v3/ 按照此处的简单指南, https://developers.google.com/analytics/devguides/collection/android/v3/

when i run my app, i get this, 当我运行我的应用程序时,我得到了这个,

10-28 18:01:17.973  27022-27069/com.foo.bar W/GAV3﹕ Thread[GAThread,5,main]: Service unavailable (code=1), will retry.
10-28 18:01:17.973  27022-27069/com.foo.bar I/GAV3﹕ Thread[GAThread,5,main]: No campaign data found.
10-28 18:01:17.973      525-865/system_process W/ActivityManager﹕ Unable to start service Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) } U=0: not found

from the debug, it's trying to start a service that doesn't exist. 从调试开始,它试图启动一个不存在的服务。 it seems like i should have to define that in my manifest, but the guide says nothing about that. 似乎我应该在我的清单中定义它,但指南没有说明这一点。

i've placed analytics.xml in my res/values folder as such, 我已将analytics.xml放在我的res / values文件夹中,

<?xml version="1.0" encoding="utf-8" ?>
<resources
    xmlns:tools="https://schemas.android.com/tools"
    tools:ignore="TypographyDashes">

  <string name="ga_trackingId">UA-XXX-1</string>
  <bool name="ga_autoActivityTracking">true</bool>
  <bool name="ga_reportUncaughtExceptions">true</bool>
  <integer name="ga_dispatchPeriod">1</integer>
  <bool name="ga_debug">true</bool>
</resources>

i'm completely stumped here since the guide is so simple. 由于指南很简单,我完全被这里难住了。 if it makes any difference (and it shouldn't), i'm building with android studio / gradle, and adding the dependency like this, 如果它有任何区别(并且它不应该),我正在使用android studio / gradle构建,并添加这样的依赖项,

compile files('libs/libGoogleAnalyticsServices.jar')

EDIT: had a thought ... this device DOES NOT run google services. 编辑:有一个想法...这个设备不运行谷歌服务。 does the google analytics lib depend on the google service APK being installed? google analytics lib是否依赖于正在安装的Google服务APK?

You can ignore that warning for now. 您现在可以忽略该警告。

From the Google Mobile App Analytics group: 来自Google移动应用分析论坛:

The SDK is simply attempting to connect to a global dispatch service, which is unavailable on your device.  The hits are still being generated and sent to GA normally.

The GA developer site will provide more information on this soon. GA开发者网站将很快提供更多相关信息。

Link to the group: https://groups.google.com/forum/#!forum/ga-mobile-app-analytics 链接到该群组: https//groups.google.com/forum/#!forum / ga-mobile-app-analytics

If you are using analytics V3 you should remove 如果您使用的是分析V3,则应删除

    <bool name="ga_debug">true</bool>

as ga_debug is for v2 因为ga_debug适用于v2

refer: Google Analytics SDK for Android - EasyTracker Parameters 参考: 适用于Android的Google AnalyticsSDK - EasyTracker参数

Same problem here, you might have just forgotten to initialize your tracker. 同样的问题,您可能忘记初始化您的智能设备。

Under "next steps" on the GA3 site , it states "Before any data can be measured, you must initialize at least one tracker via GoogleAnalytics singleton by providing a Context and a Google Analytics property ID:" GA3网站的 “后续步骤”下,它指出“在测量任何数据之前,您必须通过提供上下文和Google Analytics属性ID,通过GoogleAnalytics单例初始化至少一个跟踪器:”

Just insert this code into your main activities' onCreate method: 只需将此代码插入主要活动的onCreate方法:

// Initialize a tracker using a Google Analytics property ID.
GoogleAnalytics.getInstance(this).getTracker("UA-XXXX-Y")

You'd think they'd mention this on their main page, but I guess they just kind of expect you'll be curious about the advanced settings. 你认为他们会在他们的主页上提到这一点,但我想他们只是希望你对高级设置感到好奇。

I think you can use the 我想你可以用

GAServiceManager.getInstance().setLocalDispatchPeriod(10);

after this line it seems to work just fine and send the events 在这一行之后它似乎工作正常并发送事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM