27

in Application class, in create method I call GoogleAnalytics.getInstance(this) and application just freezes...on any device Worked fine with google play services 6.1, now it's 6.5 and I have no idea what could cause this.... Any ideas?

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'
}
Ivan Vazhnov
  • 1,291
  • 11
  • 9
  • Hi, I have the same problem. Did you fix it? The app freezes during the execution of this call : GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); I am also using com.google.android.gms:play-services:6.5.87 (this is my first use of the Android Analytics SDK). – Rolf Dec 13 '14 at 06:23
  • possible duplicate of [Android Google Analytics Causing Black Screen](http://stackoverflow.com/questions/27423750/android-google-analytics-causing-black-screen) – PaulR Dec 30 '14 at 00:33
  • I don't have a solution... but I have what might be a clue. I upgraded to V4 and everything was fine as long as I kept sending the data to our preexisting target. When I created a new one (and changed the ID in the code), only then did getInstance() hang. – Dave Owens Mar 02 '15 at 15:32
  • Did you guys still encounter the same problem, when using Google Play Services 7.0 : https://plus.google.com/+AndroidDevelopers/posts/JRfRmePSWFK – Cheok Yan Cheng Mar 12 '15 at 04:16

5 Answers5

20

Worked fine with google play services 6.1

Good, I did rollback to 6.1.+ I think it some internal error that will be fixed in an next update.

Upd

It fixed in 7.0

Kirill Shalnov
  • 2,216
  • 1
  • 19
  • 21
14

removing this line from the manifest solved the problem for me:

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

Maor Hadad
  • 1,850
  • 21
  • 36
  • 1
    helped me too, but what does this line actually do? – dragoon Dec 22 '14 at 21:18
  • Its tell it to get its data from the xml file. – Maor Hadad Dec 23 '14 at 07:49
  • 1
    To replace programatically: GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(mContext); googleAnalytics.setLocalDispatchPeriod(30); mGATracker = googleAnalytics.newTracker(mTrackerId); mGATracker.setSessionTimeout(300); mGATracker.enableExceptionReporting(true); – JY2k Jan 08 '15 at 14:54
  • 1
    Has anyone seen a good clear explanation of what global_tracker.xml does? All the tutorials out there just cut & paste the same code that serves up 3 trackers (global, app, and ecommerce) but none of them really explain what's going on and what role the xml files play... especially since the xml files don't seem to be symmetrical (and there isn't one for the ecommerce tracker) – Dave Owens Mar 02 '15 at 15:38
  • Dave Owens. Trackers can be configured from java code or by providing xml file. The example uses global_tracker.xml for the xml configuration file. Both configuration options are practically identical with the exception of enableAdvertisingIdCollection. The adid collection can only be configured from code. You can for example configure session timeout from xml with 300 or from code with tracker.setSessionTimeout(300); Both statements have the same result. – djabi Mar 21 '15 at 19:16
3

GoogleAnalytics.getInstance() deadlocks while trying to parse the xml tracker definition.

The issue is fixed in Google Play Services 7.0 that was released March 19, 2015. Upgrading to 7.0 will fix the deadlock. http://developer.android.com/google/play-services/index.html

If you must use Play Services 6.5, you can workaround the deadlock by initializing the tracker from code instead of xml resource:

public static final String TRACKER_ID="UA-xxx";
...
mTracker = analytics.newTracker(TRACKER_ID);
// Configure mTracker using the tracker provided methods
djabi
  • 5,601
  • 18
  • 25
2

I got this error:

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)

in this line:

GoogleAnalytics.getInstance(this)

The solution for me was upgrading this:

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'
}

into:

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'
}
CookieMonster
  • 1,723
  • 1
  • 15
  • 15
0

Just in case the other fixes mentioned here don't work for you, here's what worked for me:

In build.gradle I changed...

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

...to...

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

...and it stopped hanging. I don't know why.

Dave Owens
  • 450
  • 4
  • 11