谷歌分析阻止安卓应用 [英] Google Analytics blocks Android App

查看:25
本文介绍了谷歌分析阻止安卓应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Android 应用中使用了 Google Analytics,它运行良好.将 SDK(谷歌播放服务)更新到当前版本 (6587000) 后,应用在启动时在第 8 行(共 10 次)处挂断:

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.

我唯一一次获得可重现的结果是,当我从 AndroidManifest.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" />

但我的配置是正确的:

<?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>

如果我更改配置,会出现相同的结果:应用程序在 10 次中有 8 次在启动时冻结.

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?

推荐答案

我有类似的我删除了下面的代码和应用程​​序运行..

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

并为 getTracker 类添加以下代码...使用 Java 代码而不是 XML 方法构建 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);
    }

这篇关于谷歌分析阻止安卓应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆