Android Google Analytics v4 SDK not tracking realtime on July 2016

拥有回忆 提交于 2019-12-11 05:24:28

问题


I am not seeing anything, not even a nudge on realtime tracking in GA. I am running the debug build using the debugger. I did not whitelist any corporate IPs or anything, just created a basic GA account and linked it to GooglePlay Developer.

logcat shows that hit is getting dispatched

07-14 13:39:56.189  5488  5580 D GAv4    : Hit sent to the device AnalyticsService for delivery

gradle build Project

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.google.gms:google-services:3.0.0'
}

}

gradle build app

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    ...
    minSdkVersion 15
    targetSdkVersion 23
    ...
}
...

dependencies {
...
compile 'com.google.android.gms:play-services-analytics:9.2.0'
...
}
apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- Analytics dispatch -->
    <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
        android:enabled="true">
        <intent-filter>
            <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.AnalyticsService"
        android:enabled="true"
        android:exported="false"/>
    <!-- End analytics dispatch -->

    <!-- Start google tracking-->
    <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter android:priority="1000">
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <service
        android:name="com.google.android.gms.analytics.CampaignTrackingService"
        android:enabled="true"
        android:exported="false" />
    <!-- End google tracking -->

MyApplication.java

public class MyApplication extends Application {

public void onCreate() {
    super.onCreate();
    Tracker t = getTracker();
    t.send(new HitBuilders.EventBuilder().setCategory("wtfcat").setAction("wtfaction").setLabel("wtflabel").build());
}

static final String PROPERTY_ID = "UA-XXXXXX-1";
Tracker mTracker;
public synchronized Tracker getTracker() {
    if (mTracker == null) {
        GoogleAnalytics ga = GoogleAnalytics.getInstance(this);
        ga.setLocalDispatchPeriod(1);
        ga.setDryRun(false);
        ga.setAppOptOut(false);
        mTracker = ga.newTracker(PROPERTY_ID);
    }
    return mTracker;
}
}

来源:https://stackoverflow.com/questions/38380919/android-google-analytics-v4-sdk-not-tracking-realtime-on-july-2016

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