我的项目中有 Google Analytics v4 的问题。我收到错误消息未找到广告系列数据。
这是我的代码:
在活动文件中:
private void reportGoogleAnalitics(String screenName){
GoogleAnalytics.getInstance(this).newTracker(getString(R.string.google_analytics_id));
GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
tracker = ((SBTApplication) getApplication()).getTracker(TrackerName.APP_TRACKER);
tracker.setScreenName(screenName);
tracker.send(new HitBuilders.AppViewBuilder().build());
}
在我的应用程序类中:
public class SBTApplication extends Application {
private HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(getString(R.string.google_analytics_id));
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
}
那有什么问题?