我的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之前工作。我在这里缺少什么?
答案 0 :(得分:3)
你的清单中有这个吗?
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
答案 1 :(得分: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);
}
答案 2 :(得分:1)
我认为这是一个错误的事实必须是一个答案,因为项目成员已经承认它是一个错误并正在进行修复https://code.google.com/p/analytics-issues/issues/detail?id=443