How to configure dry run and log level options via XML in Google Analytics v4 SDK for Android?

若如初见. 提交于 2020-01-01 08:19:12

问题


The parameters documentation for the XML configuration file used by the Google Analytics v4 SDK (as found in the Google Play Services 4.3.23 release) says that ga_dryRun and ga_logLevel are valid attributes in the tracker file. Here is my res/xml/default_tracker.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="ga_dryRun">true</bool>
    <string name="ga_logLevel">verbose</string>
</resources>

When I set this config file on a new tracker and run my app, I see the following in the log:

04-30 13:05:55.303  29266-29266/com.example.app W/GAV3﹕ Thread[main,5,main]: bool configuration name not recognized:  ga_dryRun
04-30 13:05:55.303  29266-29266/com.example.app W/GAV3﹕ Thread[main,5,main]: string configuration name not recognized:  ga_logLevel

Are there updated attribute names to use? Is configuring these features via XML no longer supported (they worked in the v3 SDK)?

I know I can set both the dry run and log level options from Java, but it would be nice to be able to define these in the XML files so I could use different files for different build variants.


回答1:


From your setup, it looks like you are specifying the settings in a tracker configuration.

The values of ga_dryRun and ga_logLevel are global settings for the app and not specific to a particular tracker from v4 onwards. Can you make sure that you are following the steps written in the documentation here?

To quote, Use the following to setup the configuration:

In AndroidManifest.xml

 <meta-data
   android:name="com.google.android.gms.analytics.globalConfigResource"
   android:resource="@xml/analytics_global_config" />

In analytics_global_config.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
   <bool name="ga_dryRun">true</bool>
   <string name="ga_logLevel">verbose</string>
 </resources>


来源:https://stackoverflow.com/questions/23400912/how-to-configure-dry-run-and-log-level-options-via-xml-in-google-analytics-v4-sd

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