Android GoogleAnalytics getInstance

在应用程序类中,在创build方法中我调用GoogleAnalytics.getInstance(this)和应用程序只是冻结…在任何设备上工作正常与谷歌播放服务6.1,现在它是6.5,我不知道什么可能会导致此….任何想法?

public class BaseApplication extends Application { private static Tracker mTracker; private MyProfile mMyProfile; public BaseApplication() { super(); } private void initTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); mTracker.enableAdvertisingIdCollection(true); } } 

`…

 Gradle dependencies { compile project(':IMFramework') compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.android.gms:play-services-base:6.5.87' compile 'com.google.android.gms:play-services-maps:6.5.87' } 

Solutions Collecting From Web of "Android GoogleAnalytics getInstance"

与谷歌播放服务6.1工作得很好

好,我做了回滚到6.1。+我认为它会在下次更新中修复一些内部错误。

UPD

它在7.0中修复

从清单中删除这一行解决了我的问题:

元数据android:name =“com.google.android.gms.analytics.globalConfigResource”android:resource =“@ xml / global_tracker”

GoogleAnalytics.getInstance()尝试parsingxml跟踪器定义时死锁。

这个问题已在 2015年3月19日发布的Google Play Services 7.0中得到解决。升级到7.0将解决僵局。 http://developer.android.com/google/play-services/index.html

如果您必须使用Play Services 6.5,则可以通过从代码而不是xml资源初始化跟踪器来解决死锁问题:

 public static final String TRACKER_ID="UA-xxx"; ... mTracker = analytics.newTracker(TRACKER_ID); // Configure mTracker using the tracker provided methods 

我得到这个错误:

 java.lang.NoSuchMethodError: No static method zzz(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/data/com.crave.iapdemo/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-10.0.1_b9da1447b99cc6cbc2fa601fb84d0418780bfa55-classes.dex) at com.google.android.gms.analytics.internal.zzf.zzX(Unknown Source) at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source) 

在这一行:

 GoogleAnalytics.getInstance(this) 

我的解决scheme是升级这个:

 dependencies { // play services compile 'com.google.android.gms:play-services-gcm:9.0.0' compile 'com.google.android.gms:play-services-analytics:9.0.0' } 

成:

 dependencies { // play services compile 'com.google.android.gms:play-services-gcm:10.0.1' compile 'com.google.android.gms:play-services-analytics:10.0.1' } 

以防万一这里提到的其他修补程序不适合你,这是什么对我有用:

在build.gradle我改变了…

 compile 'com.google.android.gms:play-services:6.5.87' 

…至…

 compile 'com.google.android.gms:play-services-base:6.5.87' 

它停止了悬挂。 我不知道为什么。