3

我正在创建一个应用程序,我想在其中查看 google 分析帐户的崩溃和异常报告。

我为此功能使用以下代码:

“analytics_global_config.xml”

<?xml version="1.0" encoding="utf-8"?>
  <resources>
  <string name="ga_appName">app_name</string>
  <string name="ga_logLevel">verbose</string>
  <integer name="ga_dispatchPeriod">1</integer>
  <bool name="ga_dryRun">true</bool>
</resources>

我在清单文件中声明了这个 xml,如下所示:

<meta-data
    android:name="com.google.android.gms.analytics.globalConfigResource"
    android:resource="@xml/analytic_global_config" />

用于跟踪的 xml 文件:“analytics_track.xml”,如下所示:

<?xml version="1.0" encoding="utf-8"?>
 <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
    <string name="ga_trackingId">UA-XXXXXXXX-1
     </string>
    <bool name="ga_autoActivityTracking">true
     </bool>
    <bool name="ga_reportUncaughtExceptions">true
     </bool>
    <string name="ga_sampleFrequency">99.8</string>
    <integer name="ga_sessionTimeout">2000</integer>
    <bool name="ga_anonymizeIp">true</bool>

在应用程序类中,我使用了以下代码:

Tracker tracker = GoogleAnalytics.getInstance(this).(R.xml.analytics_track);

我正在登录应用程序的启动为:

09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: Loading Tracker config values.
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] trackingId loaded: UA- 54498004-1
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] sample frequency loaded: 99.8
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] session timeout loaded: 2000000
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] auto activity tracking loaded: true
09-23 16:26:57.775: V/GAV4(7763): Thread[client_id_fetcher,5,main]: Loaded client id from disk.
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] anonymize ip loaded: true
09-23 16:26:57.775: V/GAV4(7763): Thread[main,5,main]: [Tracker] anonymize ip loaded: false
09-23 16:26:57.785: V/GAV4(7763): Thread[main,5,main]: ExceptionReporter created, original handler is com.android.internal.os.RuntimeInit$UncaughtHandler
09-23 16:26:57.785: V/GAV4(7763): Thread[main,5,main]: Uncaught exceptions will be reported to Google Analytics.
09-23 16:27:02.895: V/GAV4(7763): Thread[GAThread,5,main]: connecting to Analytics service
09-23 16:27:02.985: V/GAV4(7763): Thread[main,5,main]: service connected, binder: android.os.BinderProxy@41ae4840
09-23 16:27:02.985: V/GAV4(7763): Thread[main,5,main]: bound to service
09-23 16:27:03.015: V/GAV4(7763): Thread[GAThread,5,main]: connect: bindService returned true for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
09-23 16:27:03.055: V/GAV4(7763): Thread[main,5,main]: Connected to service
09-23 16:27:03.445: I/GAV4(7763): Thread[GAThread,5,main]: No campaign data found.
09-23 16:27:03.445: V/GAV4(7763): Thread[GAThread,5,main]: Initialized GA Thread

-一段时间后”

09-23 16:32:04.910: V/GAV4(7763): Thread[disconnect check,5,main]: Disconnecting due to     inactivity
09-23 16:32:04.920: V/GAV4(7763): Thread[disconnect check,5,main]: Disconnected from service

问题是它没有给出未捕获的崩溃和异常。我手动进行接收,异常后我得到以下日志:

09-23 16:32:22.770: V/GAV4(7763): Thread[main,5,main]: Tracking Exception: ActivityNotFoundException (@FullVideoActivity:onCompletion:276) {main}
09-23 16:32:22.770: V/GAV4(7763): Thread[main,5,main]: Dispatch call queued. Dispatch will run once initialization is complete.
09-23 16:32:22.770: V/GAV4(7763): Thread[main,5,main]: Passing exception to original handler.

我没有在谷歌分析帐户上遇到任何异常和崩溃。谁能帮我解决这个问题?

谢谢伊山耆那教

4

1 回答 1

0

您没有将命中发送到服务。您应该在 Thread[GAThread,5,main]: Initialized GA Thread 之后得到以下内容:

    Thread[GAThread,5,main]: Loaded clientId
    Thread[GAThread,5,main]: putHit called
    Thread[GAThread,5,main]: Sending hit to service ..

在应用程序类中,您必须使用:

 Tracker tracker = GoogleAnalytics.getInstance(this).newTracker(R.xml.analytics_track);

如果它仍然不起作用,您还可以尝试通过在应用程序类的 onCreate() 中添加以下方法来设置 GoogleAnalytics:

private void initGoogleAnalytics() {
    GoogleAnalytics mGoogleAnalytics = GoogleAnalytics.getInstance(this);
    mGoogleAnalytics.setDryRun(false);
    mGoogleAnalytics.setLocalDispatchPeriod(10);
    mGoogleAnalytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
    mGoogleAnalytics.enableAutoActivityReports(this);
}
于 2014-11-25T12:57:47.583 回答