Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the play-services-analytics dependency not include GooglePlayServicesUtil or GoogleApiAvailability classes?

I have included the play-services-analytics library like so:

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
}

However, when I go to actually import the GoogleApiAvailability class, like the following, then Android Studio will tell me it cannot resolve symbol GoogleApiAvailability. I've tried importing the now deprecated GooglePlayServicesUtil class to no avail either

import com.google.android.gms.common.GoogleApiAvailability;

My second question would be, what do I need to include in my build.gradle file as a dependency to ensure I can import and use the GoogleApiAvailability class without having to import the entire google play services library?

I could be wrong in assuming this, but all indications of my project are pointing to the issue of play-services-analytics not including the GoogleApiAvailability class or the now deprecated GooglePlayServicesUtil.

Thanks in advance!

like image 924
w3bshark Avatar asked Dec 28 '15 15:12

w3bshark


1 Answers

You can see a list Google Play services dependencies here: https://developers.google.com/android/guides/setup

If you run gradlew dependencies on your project, you will see the following:

+--- com.google.android.gms:play-services-analytics:8.4.0
|    \--- com.google.android.gms:play-services-basement:8.4.0
|         \--- com.android.support:support-v4:23.0.0 -> 23.1.1 (*)
\--- com.google.android.gms:play-services-base:8.4.0
     \--- com.google.android.gms:play-services-basement:8.4.0 (*)

The dependnecy, compile 'com.google.android.gms:play-services-analytics:8.4.0' depends on compile 'com.google.android.gms:play-services-basement:8.4.0'.

For ConnectionResult and GoogleApiAvailability, you also need: compile 'com.google.android.gms:play-services-base:8.4.0'.

Also, new HitBuilders.AppViewBuilder().build() is deprecated in favor of new HitBuilders.ScreenViewBuilder().build().

like image 164
Jared Burrows Avatar answered Oct 09 '22 09:10

Jared Burrows