我的 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 之前工作。我在这里想念什么?