3

我的 app_tracker.xml

<string name="ga_trackingId">UA-XXXX....</string>
<string name="ga_logLevel">verbose</string>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>

我在活动中的设置代码

private void setupGoogleAnalytics() {
   MyApp app= (MyApp) getApplication();
   Tracker myTracker=app.getTracker(MyApp.TrackerName.APP_TRACKER);
   myTracker.enableAutoActivityTracking(true);
   GoogleAnalytics.getInstance(this).enableAutoActivityReports(app);
}

我的应用

public class MyApp extends Application {
    public enum TrackerName {
        APP_TRACKER // Tracker used only in this app.
    }    
    HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
    public MyApp() {
        super();
    }
    public synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            Tracker t=analytics.newTracker(R.xml.app_tracker);
            mTrackers.put(trackerId, t);
        }
        return mTrackers.get(trackerId);
    }
}

我可以发送屏幕和事件。但我只是无法通过模拟 NPE 向 Google Analytics 发送未捕获的异常。它在 V4 之前工作。我在这里想念什么?

4

3 回答 3

3

你的清单中有这个吗:

 <meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
               android:resource="@xml/global_tracker" />
于 2014-05-27T06:41:02.187 回答
2

我有同样的问题,我通过添加这一行来解决它 myTracker.enableExceptionReporting(true); 到设置方法

private void setupGoogleAnalytics() {
  MyApp app= (MyApp) getApplication();
  Tracker myTracker=app.getTracker(MyApp.TrackerName.APP_TRACKER);
  myTracker.enableAutoActivityTracking(true);
  myTracker.enableExceptionReporting(true); //add this line
  GoogleAnalytics.getInstance(this).enableAutoActivityReports(app);
}
于 2014-08-13T05:46:35.100 回答
1

我认为它是一个错误的事实必须是一个答案,因为项目成员已经承认它是一个错误并正在修复https://code.google.com/p/analytics-issues/issues/detail?id =443

于 2014-10-01T11:09:55.527 回答