我在Logcat看到了这个:
W/GAV4: String xml configuration name not recognized: ga_trackingId
W/GAV4: Bool xml configuration name not recognized: ga_autoActivityTracking
W/GAV4: Bool configuration name not recognized: ga_reportUncaughtExceptions
在Manifest.xml中我有:
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/track" />
在App.java中:
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(R.xml.track);
在track.xml中:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_trackingId">UA-****</string>
<string name="ga_logLevel">error</string>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<bool name="ga_dryRun">false</bool>
<integer name="ga_dispatchPeriod">120</integer>
</resources>
配置文件中的布尔参数是否被忽略?
答案 0 :(得分:0)
您可以从清单中删除元数据并删除track.xml
文件。而是从像这样的代码配置它:
final String trackingId = MyApplication.DEBUG ? AnalyticsManager.GA_TRACKING_ID_DEBUG
: AnalyticsManager.GA_TRACKING_ID_PROD;
final int versionCode = BuildConfigHelper.VERSION_CODE;
this.mDefaultTracker = analytics.newTracker(trackingId);
this.mDefaultTracker.enableAdvertisingIdCollection(true);
this.mDefaultTracker.enableAutoActivityTracking(false);
this.mDefaultTracker.enableExceptionReporting(false);
this.mDefaultTracker.setSessionTimeout(300);
this.mDefaultTracker.set("&av", String.valueOf(versionCode));