如何配置试运行,并通过XML在谷歌Analytics(分析)V4 SDK为Android日志级别的选择?级别、日志、Analytics、XML

2023-09-07 08:39:15 作者:外向的孤独患者

的parameters对于所使用的谷歌Analytics(分析)V4 SDK(如谷歌播放服务4.3.23版本中)的XML配置文件的文件说, ga_dryRun ga_logLevel 是跟踪文件有效属性。这是我的 RES / XML / default_tracker.xml

 < XML版本=1.0编码=UTF-8&GT?;
<资源>
    <布尔名=ga_dryRun>真< /布尔>
    <字符串名称=ga_logLevel>详细< /串>
< /资源>
 

当我设置的配置文件上的一个新的跟踪和运行我的应用程序,我看到下面的日志中:

  04-30 13:05:55.303 29266-29266 / com.example.app W / GAV3:螺纹[主,5,主]:BOOL配置名称无法识别:ga_dryRun
04-30 13:05:55.303 29266-29266 / com.example.app W / GAV3:螺纹[主,5,主]:字符串配置名称无法识别:ga_logLevel
 

是否有更新的属性名称使用?配置是通过XML不再支持这些功能(他们在第三版SDK工作)?

我知道我可以同时设置预演和日志从Java级别选项,但它会很高兴能够在XML文件中定义这些,所以我可以用不同的文件不同版本的变种。

解决方案

从你的设置,它看起来像你在跟踪器配置指定的设置。

的值 ga_dryRun ga_logLevel 是应用程序的全局设置,而不是具体的从V4特定跟踪器起。你能确保你在下列书面文档here?

在H5页面中使用Google Analytics

要引用,请使用以下设置配置:

  

在AndroidManifest.xml中

 <元数据
   机器人:名称=com.google.android.gms.analytics.globalConfigResource
   机器人:资源=@ XML / analytics_global_config/>
 

在analytics_global_config.xml

 < XML版本=1.0编码=UTF-8&GT?;
 <资源>
   <布尔名=ga_dryRun>真< /布尔>
   <字符串名称=ga_logLevel>详细< /串>
 < /资源>
 

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.

解决方案

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>