Google Analytics V4 - String xml configuration name not recognized: ga_trackingId

蹲街弑〆低调 提交于 2019-11-29 00:36:35
Edison Spencer

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!