简体   繁体   English

Android Google Analytics与服务的连接失败

[英]Android Google Analytics connection to service failed

I've implemented Google Analytics (V2) into my Android app. 我已将Google Analytics(V2)实施到我的Android应用中。 A while ago the code managed to send data to the profile (V2) succesfully. 不久前,代码成功地将数据发送到配置文件(V2)。 However now it refuses to connect to the service: 但是现在它拒绝连接到服务:

04-09 14:42:49.911: W/GAV2(8576): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
04-09 14:42:49.921: I/GAV2(8576): Thread[main,5,main]: ExceptionReporter created, original handler is com.android.internal.os.RuntimeInit$UncaughtHandler
04-09 14:42:50.051: D/libEGL(8576): loaded /system/lib/egl/libEGL_mali.so
04-09 14:42:50.061: D/libEGL(8576): loaded /system/lib/egl/libGLESv1_CM_mali.so
04-09 14:42:50.061: D/libEGL(8576): loaded /system/lib/egl/libGLESv2_mali.so
04-09 14:42:50.120: D/OpenGLRenderer(8576): Enabling debug mode 0
04-09 14:42:50.190: W/IInputConnectionWrapper(8576): showStatusIcon on inactive InputConnection
04-09 14:42:54.881: I/GAV2(8576): Thread[GAThread,5,main]: connecting to Analytics service
04-09 14:42:54.891: I/GAV2(8576): Thread[GAThread,5,main]: connect: bindService returned false for Intent { act=com.google.android.gms.analytics.service.START (has extras) }
04-09 14:42:54.901: W/GAV2(8576): Thread[GAThread,5,main]: Service unavailable (code=1), will retry.
04-09 14:42:54.941: I/GAV2(8576): Thread[GAThread,5,main]: No campaign data found.
04-09 14:42:59.911: I/GAV2(8576): Thread[Service Reconnect,5,main]: connecting to Analytics service
04-09 14:42:59.921: I/GAV2(8576): Thread[Service Reconnect,5,main]: connect: bindService returned false for Intent { act=com.google.android.gms.analytics.service.START (has extras) }
04-09 14:42:59.921: W/GAV2(8576): Thread[Service Reconnect,5,main]: Service unavailable (code=1), using local store.
04-09 14:42:59.921: I/GAV2(8576): Thread[Service Reconnect,5,main]: falling back to local store
04-09 14:42:59.971: V/GAV2(8576): Thread[GAThread,5,main]: dispatch running...
04-09 14:43:00.061: V/GAV2(8576): Thread[GAThread,5,main]: ...nothing to dispatch
04-09 14:43:00.061: I/GAV2(8576): Thread[GAThread,5,main]: PowerSaveMode initiated.
04-09 14:43:52.951: D/dalvikvm(8576): GC_CONCURRENT freed 197K, 4% free 7258K/7492K, paused 15ms+5ms, total 56ms
04-09 14:43:54.611: W/IInputConnectionWrapper(8576): showStatusIcon on inactive InputConnection

I'm pretty sure my code is sufficient since it managed to send data before. 我很确定我的代码是足够的,因为它之前设法发送数据。 These are the steps I implemented (used the Android Google Analytics V2 docs): 这些是我实施的步骤(使用Android Google Analytics V2文档):

manifest additions: 明显的补充:

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

main activity additions: 主要活动增加:

@Override
public void onStart() {

    super.onStart();
    EasyTracker.getInstance().activityStart(this);

}

@Override
public void onStop() {

    EasyTracker.getInstance().activityStop(this);
    super.onStop();
}

xml (analytics.xml) xml(analytics.xml)

<?xml version="1.0" encoding="utf-8" ?>

<resources>
  <!--tracking ID-->
  <string name="ga_trackingId">UA-(copied from profile)-1</string>

  <!--Enable automatic activity tracking-->
  <bool name="ga_autoActivityTracking">true</bool>

  <!--Enable automatic exception tracking-->
  <bool name="ga_reportUncaughtExceptions">true</bool>

  <!--Enable debug tracking-->
  <bool name="ga_debug">true</bool>

  <integer name="ga_dispatchPeriod">20</integer>
</resources>

I get the warnings at the very launch of the app. 我在应用程序启动时收到警告。 I've tried creating a new profile/account. 我试过创建一个新的个人资料/帐户。 I've tried using & #45; 我尝试过使用&#45; and & #8211; 和&#8211; instead of the dashes. 而不是破折号。 It's been 30+ hours since last data was received on the profile, since then the above logcat lines. 自从上次收到关于配置文件的数据以来已经过了30多个小时,从那时起上面的logcat行。

Any ideas how this is caused? 任何想法是如何造成的?

Might not to be your case but here it goes anyways. 可能不是你的情况,但在这里反正。

I had analytics working fine in my app. 我的应用程序中的分析工作正常。 I was using Eclipse and decided to switch to Intellij IDE. 我正在使用Eclipse并决定切换到Intellij IDE。 When I did it, the IDE showed me a typografic warning on the dash character of my analytics.xml file (regarding ga_trackingId). 当我这样做时,IDE在我的analytics.xml文件的破折号字符上显示了一个类似的警告(关于ga_trackingId)。 When I made the change (invisible to the human eye) the warning went away but analytics just stopped working. 当我做出改变(人眼看不到)时,警告就消失了,但分析工作就停止了。

Might be something with the encoding of the file, whatever, but I my case I had to type the dash character and not paste it (and also add a tools:ignore="TypographyDashes" in my file to get rid of the warning). 可能是文件编码的东西,无论如何,但我的情况我必须键入短划线字符而不是粘贴它(并且还在我的文件中添加工具:ignore =“TypographyDashes”以消除警告)。

Not sure if this is important but my analytics.xml lives in "values" rather than in "xml" and it works fine. 不确定这是否重要,但我的analytics.xml存在于“值”而不是“xml”中,并且工作正常。

Here is how it looks. 这是它的外观。 Hope this helps. 希望这可以帮助。

<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">

    <!-- Replace placeholder ID with your tracking ID -->
    <string name="ga_trackingId">UA-8158474-29</string>

    <!-- Enable automatic activity tracking -->
    <bool name="ga_autoActivityTracking">true</bool>

    <integer name="ga_dispatchPeriod">40</integer>

    <!-- Enable automatic exception tracking -->
    <bool name="ga_reportUncaughtExceptions">true</bool>

</resources>

ga_debug make this to false and try once. ga_debug将其设为false并尝试一次。 probably you will get it. 可能你会得到它。

<!--Enable debug tracking-->
<bool name="ga_debug">false</bool>

Have you checked on the Google Analytics web UI that you are not actually receiving anything? 您是否在Google Analytics(分析)网络用户界面上查看了您实际上没有收到任何内容?

I have also the debug print that states no connectivity but my code still works (and I use EasyTracker as well). 我还有调试打印,说明没有连接,但我的代码仍然有效(我也使用EasyTracker)。 I am receiving events when I check it on the web UI. 我在网络用户界面上查看时收到了活动。 Is this your case as well? 这也是你的情况吗? Unfortunately I don't know why the debug says it has no connection. 不幸的是,我不知道为什么调试说它没有连接。

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

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