Google Analytics(分析)未显示android studio项目的任何数据

2017-06-08 android-studio google-analytics

我遵循https://developers.google.com/analytics/devguides/collection/android/v4/在我的android应用中实现了Google Analytics(分析)。但是它没有显示任何数据。 有人可以帮忙吗? 清单文件:

 <application
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name=".AnalyticsApplication">
        <activity android:name="com.xxx.xxxx.SplashScreen" 
       android:screenOrientation="portrait">
       <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    <activity android:name="com.xxx.xxxx.LoginScreen" 
    android:screenOrientation="portrait"/>
        <activity android:name="com.xxx.xxxx.ForgotPasswordScreen" 
    android:screenOrientation="portrait"/>
        <activity android:name="com.xx.xxx.SignupScreen" 
    android:screenOrientation="portrait"/>
        <activity android:name="com.xxx.xxx.HomeScreen" 
    android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.xxx.xxxx.SplashScreen" />
            <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>

    </application>

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

AnalyticsApplication

    public class AnalyticsApplication  extends Application {

    private static GoogleAnalytics sAnalytics;
    private static Tracker mTracker;

    @Override
    public void onCreate() {
        super.onCreate();

        sAnalytics = GoogleAnalytics.getInstance(this);
    }

    synchronized public Tracker getDefaultTracker() {
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        if (mTracker == null) {
            mTracker = sAnalytics.newTracker(R.xml.global_tracker);
        }

        return mTracker;
    }
    }

主屏幕

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.home_screen);
        Helper.printLog(tag, "onCreate");

        AnalyticsApplication application = (AnalyticsApplication) 
        getApplication();
        mTracker = application.getDefaultTracker();

        mTracker.setScreenName("home screen");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
     }
     onclick(){
     mTracker.send(new HitBuilders.EventBuilder()
                    .setCategory("Action account")
                    .setAction("account clicked")
                    .build());
           changeFragment(new AccountFragment());
    }

应用程序等级

 dependencies{
     compile 'com.google.android.gms:play-services-analytics:10.2.4'}

项目等级

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.2'
    classpath 'com.google.gms:google-services:3.0.0'

}

Answers

尝试Firebase Analytics Firebase是一种Google产品,用于构建高质量的应用程序及其使用Google Analytics(分析)。 Firebase和Google Analytics(分析)相同

前往-https: //firebase.google.com/docs/analytics/ 希望有帮助

Related