我的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之前工作。我错过了什么?

最佳答案

你的清单上有这个吗:

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

07-24 15:28