I've found the official guide to google analytics for android (https://developers.google.com/analytics/devguides/collection/android/v4/) lacking in comprehensive examples. Trying to implement it has been confusing so far.
First issue:
This is how my getTracker in a subclass of Application looks like
public synchronized Tracker getTracker() {
if (_globalTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
return analytics.newTracker(R.xml.global_tracker);
}
return _globalTracker;
}
But eclipse says "global_tracker cannot be resolved or is not a field" even though I've created an XML file called global_tracker.xml -- its under res/xml as directed in the tutorial
Second issue:
In one of my activities, I try to get the tracker to send a screen view, as detailed in the tutorial:
// Get tracker.
Tracker t = ((StorageApplication) getApplication()).getTracker();
// Send a screen view.
t.send(new HitBuilders.AppViewBuilder().build());
Unfortunately, eclipse says "HitBuilders cannot be resolved to a type" even though I'm pretty sure I have google play services and analytics imported and referenced properly (I also use geolocation and other services from google play services and they all work; analytics is imported properly because there is no issue with resolving Tracker).
Anyone have any pointers? I'd really appreciate your help -- been left wondering why this is so confusing!