本文介绍了谷歌Analytics(分析)块Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Andr​​oid应用程序使用谷歌Analytics(分析)和它工作得很好。更新的SDK(谷歌Play业务),为当前版本(6587000)应用程序挂断在启动时在下面的10倍,8号线后:

I use Google Analytics in my Android App and it works well. After updating the SDK (google play service) to the current version (6587000) the app hangs up at startup at following line 8 of 10 times:

GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

有一个在控制台中没有错误。我加成就和排行榜太多,但分析被称为第一。我也改变了环境,但有时工作,有时没有。

There is no error in console. I added Achievements and Leaderboards too, but Analytics is called first. I also changed the context, but that works sometimes and sometimes not.

我唯一一次获得可再现的结果是,当我删除下面的的Andr​​oidManifest.xml行。那么有没有冻结在启动了。

The only time I get a reproducable result is, when I remove following lines from AndroidManifest.xml. Then there is no freeze at startup anymore.

<meta-data
        android:name="com.google.android.gms.analytics.globalConfigResource"
        android:resource="@xml/analytics_global_config" />

不过,我的配置是正确的:

But my configuration is correct:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <string name="ga_appName">TestAppName</string>
  <string name="ga_appVersion">Version1.0</string>
  <string name="ga_logLevel">verbose</string>
  <integer name="ga_dispatchPeriod">1000</integer>
  <bool name="ga_dryRun">true</bool>
</resources>

如果我更改配置有相同的结果:8 10倍的应用程序冻结在启动

And if I change the configuration there is the same result: 8 of 10 times the App freezes at startup.

是否有人有线索的问题是什么,或者什么别的我可以检查,以我的应用程序再次运行在启动时不结冰?

Does someone have a clue what the problem is or what else I can check to make my app running again without freezing at startup?

推荐答案

我有类似我删除了低于code和应用程序运行。

i had similar i removed the below code and application runs..

<meta-data
        android:name="com.google.android.gms.analytics.globalConfigResource"
        android:resource="@xml/analytics_global_config" />

和增加以下$ C $下getTracker类......构建用java code,而不是XML approch的GoogleAnalytics

and add following code for getTracker class... build the GoogleAnalytics using java code rather than XML approch

synchronized Tracker getTracker(TrackerName trackerId) {
        Log.d(TAG, "getTracker()");
        if (!mTrackers.containsKey(trackerId)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

            // Global GA Settings
            // <!-- Google Analytics SDK V4 BUG20141213 Using a GA global xml freezes the app! Do config by coding. -->
            analytics.setDryRun(false);

            analytics.getLogger().setLogLevel(Logger.LogLevel.INFO);
            //analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);

            // Create a new tracker
            Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(R.xml.ga_tracker_config) : null;
            if (t != null) {
                t.enableAdvertisingIdCollection(true);
            }
            mTrackers.put(trackerId, t);
        }
        return mTrackers.get(trackerId);
    }

这篇关于谷歌Analytics(分析)块Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:38