Android Google Analytics - 与服务的连接失败

时间:2022-08-21 15:18:54

Just started implementing Google Analytics V2 in my Android application, though I'm having troubles.

刚刚开始在我的Android应用程序中实施Google Analytics V2,尽管我遇到了麻烦。

I believe I've set up an acount with a property and profiles correctly. I've supplied my key in the analytics.xml file and in each activity I use the

我相信我已经正确设置了属性和配置文件的帐户。我已经在analytics.xml文件和我使用的每个活动中提供了我的密钥

EasyTracker.getInstance().activityStart(this); in the onStart method

。EasyTracker.getInstance()activityStart(本);在onStart方法中

and

EasyTracker.getInstance().activityStop(this); in the onStop method of every activity.

。EasyTracker.getInstance()activityStop(本);在每个活动的onStop方法中。

However I don't seem to see any results on the Google Analytics website. Moreover, I turned on the debug options and I can see in log cat various messages from Gav2 (Google Analytics), implying on a problem.

但是,我似乎没有在Google Analytics网站上看到任何结果。此外,我打开了调试选项,我可以在log cat中看到来自Gav2(Google Analytics)的各种消息,这意味着一个问题。

For example

例如

11-04 21:56:48.000: W/GAV2(6376): Thread[main,5,main]: **Connection to service failed 1**
11-04 21:56:48.040: W/GAV2(6376): Thread[main,5,main]: **Need to call initialize() and be in fallback mode to start dispatch.**
11-04 21:56:48.050: I/GAV2(6376): Thread[main,5,main]: ExceptionReporter created, original handler is com.keypod.utils.AppCrashExceptionHandler
11-04 21:56:50.055: I/GAV2(6376): Thread[GAThread,5,main]: No campaign data found.
11-04 21:56:50.060: I/GAV2(6376): Thread[GAThread,5,main]: putHit called
11-04 21:56:50.410: I/GAV2(6376): Thread[GAThread,5,main]: putHit called
11-04 21:56:53.035: I/GAV2(6376): Thread[Service Reconnect,5,main]: connecting to Analytics service
11-04 21:56:53.035: I/GAV2(6376): Thread[Service Reconnect,5,main]: connect: bindService returned false for Intent { act=com.google.android.gms.analytics.service.START (has extras) }
**11-04 21:56:53.035: W/GAV2(6376): Thread[Service Reconnect,5,main]: Connection to service failed 1
11-04 21:56:53.035: I/GAV2(6376): Thread[Service Reconnect,5,main]: falling back to local store**
11-04 21:56:53.040: I/GAV2(6376): Thread[GAThread,5,main]: Sending hit to store
11-04 21:56:53.100: I/GAV2(6376): Thread[GAThread,5,main]: Sending hit to store
11-04 21:56:53.150: V/GAV2(6376): Thread[GAThread,5,main]: dispatch running...

It seems like it can't connect and then it "fallsback" to local store. Am I doing something wrong? Or should I just ignore that warning and wait for the results to show up on the site?

它似乎无法连接,然后它“回退”到本地商店。难道我做错了什么?或者我应该忽略该警告并等待结果显示在网站上?

I followed Google's guide step-by-step.

我一步一步地跟着Google的指南。

Thanks!

谢谢!

4 个解决方案

#1


26  

I can now see results in my analytics page so apparently I just needed to wait.

我现在可以在我的分析页面中看到结果,所以显然我只需要等待。

Google should do something about that warning, it can be misleading.

谷歌应该对此警告采取措施,这可能会产生误导。

Update: An interesting thing I've noticed which may also help, Google Analytics web interface doesn't show data from the current day on default. In order to view the data collected from the current day, you need to click on the date range picker on the top-right side, and select the current day from the Calendar (or Today from the combobox).

更新:我注意到有趣的事情也可能有所帮助,Google Analytics网络界面默认情况下不显示当天的数据。要查看当天收集的数据,您需要单击右上角的日期范围选择器,然后从日历(或组合框中的今天)中选择当前日期。

#2


5  

One more thing about it - dont be surprised if you wont see your tracks in Real-Time report - ga_dispatchPeriod is set to 30 mins by default

关于它的另一件事 - 如果您在实时报告中看不到您的曲目,请不要感到惊讶 - ga_dispatchPeriod默认设置为30分钟

#3


2  

Just an addition that might save you hours to debug. I did not see local debug messages of gav2 in logcat. I would only see four gav2 startup messages like "need to call initialize.." and "Service Unavailable". Though i did see views in Google Analytics Real-Time reports.

只需添加一些内容即可节省您的调试时间。我没有在logcat中看到gav2的本地调试消息。我只会看到四个gav2启动消息,例如“需要调用初始化...”和“服务不可用”。虽然我确实在Google Analytics实时报告中看到了观看次数。

What happened: i started with the following line in onStart()

发生了什么:我开始使用onStart()中的以下行

EasyTracker.getInstance().activityStart(this); 

And than turned debugging on from onCreate();

而不是从onCreate()开启调试;

GoogleAnalytics.getInstance(getApplicationContext()).setDebug(true);

This is obviously wrong as onCreate() is executed before onStart(). Now i have both set sequentially from onStart().

这显然是错误的,因为onCreate()在onStart()之前执行。现在我从onStart()顺序设置。

EasyTracker.getInstance().activityStart(this); 
GoogleAnalytics.getInstance(getApplicationContext()).setDebug(true);

What went wrong?

什么地方出了错?

I followed the Google example for GAV2 Beta 4 (https://developers.google.com/analytics/devguides/collection/android/v2/advanced). It starts out the to onStart() code:

我按照Google的GAV2 Beta 4示例(https://developers.google.com/analytics/devguides/collection/android/v2/advanced)。它从onStart()代码开始:

EasyTracker.getInstance().activityStart(this); 

Than to enable debugging and adding event tracking, i followed the Advanced examples. Without really thinking i added to onCreate (just like the example):

为了启用调试和添加事件跟踪,我遵循了高级示例。没有真正想到我添加到onCreate(就像示例):

googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext())

I used googleAnalytics to enable debugging and events. As it does not throw exceptions and it actually produces results in Google Analytics, i just did not notice the mistake for some time. Ofcourse the gav2 startup logcat message indicates that something is wrong. But if you are not familiar with gav2 this might as well be 'normal' behaviour.

我使用googleAnalytics来启用调试和事件。因为它不会抛出异常并且实际上会在Google Analytics中产生结果,所以我只是暂时没有注意到这个错误。当然,gav2启动logcat消息表明出现了问题。但是如果你不熟悉gav2,这可能也是“正常”行为。

As more people might follow the same example and learning curve, i thought i might take a moment and write it down, hope it saved you some time. If you don't see messages like "putHit called" in logcat, you might have a similar problem. Good luck.

随着越来越多的人可能会遵循相同的例子和学习曲线,我想我可能会花一点时间把它写下来,希望它能为你节省一些时间。如果你没有在logcat中看到像“putHit called”这样的消息,你可能会遇到类似的问题。祝你好运。

#4


0  

In your mainActivity onCreate() just add the following lines:

在mainActivity onCreate()中添加以下行:

GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext());
googleAnalytics.setAppOptOut(false); 

#1


26  

I can now see results in my analytics page so apparently I just needed to wait.

我现在可以在我的分析页面中看到结果,所以显然我只需要等待。

Google should do something about that warning, it can be misleading.

谷歌应该对此警告采取措施,这可能会产生误导。

Update: An interesting thing I've noticed which may also help, Google Analytics web interface doesn't show data from the current day on default. In order to view the data collected from the current day, you need to click on the date range picker on the top-right side, and select the current day from the Calendar (or Today from the combobox).

更新:我注意到有趣的事情也可能有所帮助,Google Analytics网络界面默认情况下不显示当天的数据。要查看当天收集的数据,您需要单击右上角的日期范围选择器,然后从日历(或组合框中的今天)中选择当前日期。

#2


5  

One more thing about it - dont be surprised if you wont see your tracks in Real-Time report - ga_dispatchPeriod is set to 30 mins by default

关于它的另一件事 - 如果您在实时报告中看不到您的曲目,请不要感到惊讶 - ga_dispatchPeriod默认设置为30分钟

#3


2  

Just an addition that might save you hours to debug. I did not see local debug messages of gav2 in logcat. I would only see four gav2 startup messages like "need to call initialize.." and "Service Unavailable". Though i did see views in Google Analytics Real-Time reports.

只需添加一些内容即可节省您的调试时间。我没有在logcat中看到gav2的本地调试消息。我只会看到四个gav2启动消息,例如“需要调用初始化...”和“服务不可用”。虽然我确实在Google Analytics实时报告中看到了观看次数。

What happened: i started with the following line in onStart()

发生了什么:我开始使用onStart()中的以下行

EasyTracker.getInstance().activityStart(this); 

And than turned debugging on from onCreate();

而不是从onCreate()开启调试;

GoogleAnalytics.getInstance(getApplicationContext()).setDebug(true);

This is obviously wrong as onCreate() is executed before onStart(). Now i have both set sequentially from onStart().

这显然是错误的,因为onCreate()在onStart()之前执行。现在我从onStart()顺序设置。

EasyTracker.getInstance().activityStart(this); 
GoogleAnalytics.getInstance(getApplicationContext()).setDebug(true);

What went wrong?

什么地方出了错?

I followed the Google example for GAV2 Beta 4 (https://developers.google.com/analytics/devguides/collection/android/v2/advanced). It starts out the to onStart() code:

我按照Google的GAV2 Beta 4示例(https://developers.google.com/analytics/devguides/collection/android/v2/advanced)。它从onStart()代码开始:

EasyTracker.getInstance().activityStart(this); 

Than to enable debugging and adding event tracking, i followed the Advanced examples. Without really thinking i added to onCreate (just like the example):

为了启用调试和添加事件跟踪,我遵循了高级示例。没有真正想到我添加到onCreate(就像示例):

googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext())

I used googleAnalytics to enable debugging and events. As it does not throw exceptions and it actually produces results in Google Analytics, i just did not notice the mistake for some time. Ofcourse the gav2 startup logcat message indicates that something is wrong. But if you are not familiar with gav2 this might as well be 'normal' behaviour.

我使用googleAnalytics来启用调试和事件。因为它不会抛出异常并且实际上会在Google Analytics中产生结果,所以我只是暂时没有注意到这个错误。当然,gav2启动logcat消息表明出现了问题。但是如果你不熟悉gav2,这可能也是“正常”行为。

As more people might follow the same example and learning curve, i thought i might take a moment and write it down, hope it saved you some time. If you don't see messages like "putHit called" in logcat, you might have a similar problem. Good luck.

随着越来越多的人可能会遵循相同的例子和学习曲线,我想我可能会花一点时间把它写下来,希望它能为你节省一些时间。如果你没有在logcat中看到像“putHit called”这样的消息,你可能会遇到类似的问题。祝你好运。

#4


0  

In your mainActivity onCreate() just add the following lines:

在mainActivity onCreate()中添加以下行:

GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext());
googleAnalytics.setAppOptOut(false);