【问题标题】:Android Google Analytics connection to service failedAndroid Google Analytics 连接到服务失败
【发布时间】:2013-04-09 08:19:11
【问题描述】:

我已在我的 Android 应用中实施了 Google Analytics (V2)。不久前,代码成功地将数据发送到配置文件(V2)。但是现在它拒绝连接到服务:

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

我很确定我的代码已经足够了,因为它之前可以发送数据。这些是我实施的步骤(使用 Android Google Analytics V2 文档):

清单补充:

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

主要活动补充:

@Override
public void onStart() {

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

}

@Override
public void onStop() {

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

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>

我在应用程序启动时收到警告。我试过创建一个新的个人资料/帐户。我试过使用 & #45;和–而不是破折号。自从在配置文件中收到最后一个数据以来,已经 30 多个小时了,从那时起就出现了上述 logcat 行。

你知道这是怎么造成的吗?

【问题讨论】:

标签: android service google-analytics connection


【解决方案1】:

可能不是你的情况,但无论如何都是这样。

我的应用程序中的分析工作正常。我正在使用 Eclipse,并决定切换到 Intellij IDE。当我这样做时,IDE 在我的 analytics.xml 文件的破折号字符上显示了一个印刷警告(关于 ga_trackingId)。当我做出改变(肉眼看不到)时,警告消失了,但分析停止工作。

可能与文件的编码有关,无论如何,但我的情况是我必须输入破折号而不是粘贴它(并且还添加一个工具:ignore="TypographyDashes" 在我的文件中消除警告)。

【讨论】:

    【解决方案2】:

    不确定这是否重要,但我的 analytics.xml 存在于“值”而不是“xml”中,并且工作正常。

    这是它的外观。希望这会有所帮助。

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

    【讨论】:

      【解决方案3】:

      ga_debug 将此设置为 false 并尝试一次。也许你会得到它。

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

      【讨论】:

        【解决方案4】:

        您是否在 Google Analytics(分析)网络 UI 上检查过您实际上没有收到任何信息?

        我也有调试打印表明没有连接,但我的代码仍然有效(我也使用 EasyTracker)。当我在 Web UI 上查看事件时,我收到了事件。这也是你的情况吗?不幸的是,我不知道为什么调试器说它没有连接。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-05-01
          • 2017-09-10
          • 1970-01-01
          • 2015-09-27
          • 1970-01-01
          • 1970-01-01
          • 2015-01-18
          • 2012-08-18
          相关资源
          最近更新 更多