Android - 使用Google Analytics时屏幕上没有任何内容

时间:2021-11-20 13:40:55

I have implemented Google Analytics API on my app but when I try to send a track, screen cannot be rendered.

我已经在我的应用上实施了Google AnalyticsAPI,但是当我尝试发送曲目时,无法呈现屏幕。

My application class (ETApp.class):

我的应用程序类(ETApp.class):

private static final String PROPERTY_ID = "XX-XXXXXXXX-1";
    public static int GENERAL_TRACKER = 0;
    public enum TrackerName {
        APP_TRACKER, GLOBAL_TRACKER, ECOMMERCE_TRACKER,
    }
    public HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();

...

public synchronized Tracker getTracker(TrackerName appTracker) {
        if (!mTrackers.containsKey(appTracker)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            Tracker t = (appTracker == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID) : (appTracker == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) : analytics.newTracker(R.xml.ecommerce_tracker);
            mTrackers.put(appTracker, t);
        }
        return mTrackers.get(appTracker);
    }

MainActivity.java (in onCreate event):

MainActivity.java(在onCreate事件中):

Tracker t = ((ETApp) this.getApplication()).getTracker(ETApp.TrackerName.APP_TRACKER);
t.setScreenName("MainActivity");
t.send(new HitBuilders.AppViewBuilder().build());

app_tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="ga_trackingId">XX-XXXXXXXX-1</string>

    <bool name="ga_autoActivityTracking">true</bool>
    <bool name="ga_reportUncaughtExceptions">true</bool>

    <string name="ga_appName">MyAppName</string>
    <string name="ga_appVersion">0.0.1</string>

    <bool name="ga_debug">true</bool>

    <item name="ga_dispatchPeriod" format="integer" type="integer">120</item>

    <string name="ga_sampleFrequency">90</string>

    <bool name="ga_anonymizeIp">true</bool>
    <bool name="ga_dryRun">false</bool>

    <string name="ga_sampleFrequency">100.0</string>

    <integer name="ga_sessionTimeout">-1</integer>

    <string name="com.myapp.name">MainActivity</string>

</resources>

ecommerce_tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="ga_sessionTimeout">60</integer>
    <string name="ga_trackingId">XX-XXXXXXXX-1</string>
</resources>

global_tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="TypographyDashes">

    <integer name="ga_sessionTimeout">300</integer>

    <bool name="ga_autoActivityTracking">true</bool>

    <screenName name="com.google.android.gms.analytics.samples.mobileplayground.ScreenviewFragment">
        MyApp ScreenViewScreen
    </screenName>
    <screenName name="com.google.android.gms.analytics.samples.mobileplayground.EcommerceFragment">
        MyApp EcommerceScreen
    </screenName>

    <string name="ga_trackingId">XX-XXXXXXXX-1</string>

</resources>

I have also put meta tags into manifest between tags:

我还将meta标签放入标签之间的清单中:

<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" />

But when I run my app, I get this screen and nothing else happens. Additionally, I can track on dashboard sometimes, but not always. What might be the problem?

但当我运行我的应用程序时,我得到了这个屏幕,没有其他任何事情发生此外,我有时可以在仪表板上进行跟踪,但并非总是如此。可能是什么问题?

Android  - 使用Google Analytics时屏幕上没有任何内容

Edit: It also doesn't log GoogleAnalyticsTracker

编辑:它也不会记录GoogleAnalyticsTracker

1 个解决方案

#1


0  

You are probably using Google Play Services 6.5 and you are experiencing the deadlock in GoogleAnalytics.getInstance - GoogleAnalytics.getInstance(this) not respond

您可能正在使用Google Play Services 6.5并且您遇到了GoogleAnalytics.getInstance中的死锁 - GoogleAnalytics.getInstance(this)没有回应

Try upgrading to Google Play Services 7.0 or later. The deadlock bug was fixed in GPS 7.0.

尝试升级到Google Play Services 7.0或更高版本。死锁错误已在GPS 7.0中修复。

#1


0  

You are probably using Google Play Services 6.5 and you are experiencing the deadlock in GoogleAnalytics.getInstance - GoogleAnalytics.getInstance(this) not respond

您可能正在使用Google Play Services 6.5并且您遇到了GoogleAnalytics.getInstance中的死锁 - GoogleAnalytics.getInstance(this)没有回应

Try upgrading to Google Play Services 7.0 or later. The deadlock bug was fixed in GPS 7.0.

尝试升级到Google Play Services 7.0或更高版本。死锁错误已在GPS 7.0中修复。