我正在尝试将gav 4集成到我的应用程序中。我遵循了教程,但分析不计算我的统计数据。
这是我的班级:
public class Trackers extends Application
{
public enum TrackerName
{
APP_TRACKER,
GLOBAL_TRACKER,
ECOMMERCE_TRACKER,
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public synchronized Tracker getTracker(TrackerName trackerId)
{
if (!mTrackers.containsKey(trackerId))
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
if( trackerId == TrackerName.GLOBAL_TRACKER )
{
Log.w("Anal","ok");
mTrackers.put(trackerId, analytics.newTracker(R.xml.global_tracker));
}
}
return mTrackers.get(trackerId);
}
}
global_tracker.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="TypographyDashes">
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- The screen names that will appear in reports -->
<screenName name="com.impact.ribony.MainActivity">MainActivity</screenName>
<!-- The following value should be replaced with correct property id. -->
<string name="ga_trackingId">UA-XXXXXX-X</string>
<integer name="ga_sessionTimeout">300</integer>
<string name="ga_logLevel">verbose</string>
</resources>
onStart()方法:
@Override
protected void onStart()
{
super.onStart();
Tracker t = ((Trackers) getApplication()).getTracker(Trackers.TrackerName.GLOBAL_TRACKER);
t.setScreenName("Main");
t.send(new HitBuilders.AppViewBuilder().build());
}
Mainifest文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxxxx.xxxxx"
android:versionCode="8"
android:versionName="1.0.7" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:name=".Trackers"
android:allowBackup="true"
android:icon="@drawable/ribony_top_icon"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value=".MainActivity" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
这是日志:
11-07 09:30:40.293: V/GAV4(1520): Thread[GAThread,5,main]: connect: bindService returned false for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
11-07 09:30:40.293: W/GAV4(1520): Thread[GAThread,5,main]: Service unavailable (code=1), will retry.
11-07 09:30:40.293: I/GAV4(1520): Thread[GAThread,5,main]: No campaign data found.
11-07 09:30:40.293: V/GAV4(1520): Thread[GAThread,5,main]: Initialized GA Thread
11-07 09:30:40.293: V/GAV4(1520): Thread[GAThread,5,main]: Loaded clientId
11-07 09:30:40.293: V/GAV4(1520): Thread[GAThread,5,main]: putHit called
11-07 09:30:40.293: V/GAV4(1520): Thread[GAThread,5,main]: connecting to Analytics service
11-07 09:30:45.297: V/GAV4(1520): Thread[Service Reconnect,5,main]: connecting to Analytics service
11-07 09:30:45.297: V/GAV4(1520): Thread[Service Reconnect,5,main]: connect: bindService returned false for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
11-07 09:30:45.297: V/GAV4(1520): Thread[Service Reconnect,5,main]: falling back to local store
11-07 09:30:45.297: V/GAV4(1520): Thread[GAThread,5,main]: Sending hit to store PATH: https: PARAMS: v=1, ul=en-us, t=screenview, ht=1415352635299, sr=1080x1776, a=2097658927, an=Ribony, tid=UA-42075172-3, aid=com.impact.ribony, cid=972936b4-4a71-4418-ba4a-e77cb965702d, av=1.0.7, _u=.nKK-AL, cd=Main,
11-07 09:30:45.297: W/GAV4(1520): Thread[Service Reconnect,5,main]: Service unavailable (code=1), using local store.
11-07 09:30:45.305: V/GAV4(1520): Thread[GAThread,5,main]: PowerSaveMode initiated.
11-07 09:30:45.313: V/GAV4(1520): Thread[GAThread,5,main]: PowerSaveMode terminated.
11-07 09:30:45.313: V/GAV4(1520): Thread[GAThread,5,main]: Dispatch running...
11-07 09:30:45.317: V/GAV4(1520): Thread[GAThread,5,main]: User-Agent: GoogleAnalytics/3.0 (Linux; U; Android 4.4.2; en-us; Samsung Galaxy S5 - 4.4.2 - API 19 - 1080x1920 Build/KOT49H)
11-07 09:30:45.317: V/GAV4(1520): Host: ssl.google-analytics.com
11-07 09:30:45.317: V/GAV4(1520): GET /collect?ul=en-us&ht=1415352635299&sr=1080x1776&a=2097658927&aid=com.impact.ribony&cid=972936b4-4a71-4418-ba4a-e77cb965702d&av=1.0.7&v=1&t=screenview&an=Ribony&tid=UA-42075172-3&_u=.nKK-AL&_v=ma4.0.3&cd=Main&qt=10025&z=65 HTTP/1.1
11-07 09:30:46.029: V/GAV4(1520): Thread[GAThread,5,main]: sent 1 of 1 hits
11-07 09:30:46.037: V/GAV4(1520): Thread[GAThread,5,main]: PowerSaveMode initiated.
我正在寻找我的小组,我看不到任何活动。 (我还查看了实时报告,它是空的。)
问题出在哪里?我该如何解决?