Don't know if it's too late or not, but I had the same things as you, since I was following the tutorial from Google from here and another one here.
However, when testing, I found out that a couple of services were not being defined in the Manifest file, and I found the solution for that here, as you might have also since you are already doing that correctly.
Now, for the part that might be missing, I have two files defined in my res/xml folder, app_tracker.xml
and global_tracker.xml
.
On the first one, app_tracker.xml
I have defined the following:
<!-- Replace placeholder ID with your tracking ID -->
<string name="ga_trackingId" tools:ignore="TypographyDashes" translatable="false">UA-????????-?</string>
<!-- Percentage of events to include in reports -->
<string name="ga_sampleFrequency" translatable="false">100.0</string>
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- catch and report uncaught exceptions from the app -->
<bool name="ga_reportUncaughtExceptions">true</bool>
<!-- How long a session exists before giving up -->
<integer name="ga_sessionTimeout">-1</integer>
<!-- Screen names Override -->
<screenName name="com.example.analytics.MainActivity">Main Screen</screenName>
<!-- other screens -->
And I am using app_tracker.xml
when declaring it on the Application class, e.g.
public synchronized Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
mTracker = analytics.newTracker(R.xml.app_tracker);
}
return mTracker;
}
As for the global_tracker.xml
, I have the following:
<!-- the Local LogLevel for Analytics -->
<string name="ga_logLevel">verbose</string>
<!-- how often the dispatcher should fire -->
<integer name="ga_dispatchPeriod">60</integer>
<!-- Send hits to Google Analytics. true = don't send -->
<bool name="ga_dryRun">false</bool>
And I use it by defining it on the Manifest file, such as:
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource" android:resource="@xml/global_tracker" />
And with this, I do not have those configuration name not recognized
warnings and I have the hits being received on the Analytics Overview
Hope I was able to help :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…