Reputation: 4305
I switched from Google Play Services 11.0.4 to 18.1.1 and got the compiler error in the following code:
public boolean isGooglePlayServicesAvailable()
{
com.google.android.gms.common.GoogleApiAvailability googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance();
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this);
return resultCode == com.google.android.gms.common.ConnectionResult.SUCCESS;
}
The error message is:
MainActivity.java:246: error: cannot find symbol
com.google.android.gms.common.GoogleApiAvailability googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance();
^
symbol: class GoogleApiAvailability
location: package com.google.android.gms.common
Is GoogleApiAvailability available in Google Play Services 18.1.1?
In build.gradle
I have this:
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.google.android.gms:play-services-ads:18.1.1'
}
EDIT1:
There is com.google.android.gms.common.GoogleApiAvailabilityLight
at least.
Upvotes: 3
Views: 5220
Reputation: 6936
Just add this dependency in your build.gradle(:app) -
`implementation "com.google.android.gms:play-services-location:16.0.0"`
Upvotes: 2
Reputation: 121
I faced the same issue. After upgrading some Google Mobile Services (GMS) libraries GoogleApiAvailability
class disappeared.
Looks like Google had been loosening its dependency on GMS recently. I failed to find some useful information across the web, so I decided to look through source code of GoogleApiAvailability
and try to figure out the difference between GoogleApiAvailability
& GoogleApiAvailabilityLight
.
It seems to me that main difference is as follows: GoogleApiAvailabilityLight
helps to check, yes, availability of GMS services on device, but GoogleApiAvailability
also helps restore GMS functionality, if broken or outdated. This restoration techniques seem to be aware of GMS & need them. So Google separated 2 classes: one for checking (GMS independent), other - for checking + restoration (GMS dependent).
As my only need was to check GMS's availability - I replaced GoogleApiAvailability
with GoogleApiAvailabilityLight
and thats it.
Hope this helps someone who will face the same issue.
Upvotes: 10
Reputation: 4305
Looks like it is now com.google.android.gms.common.GoogleApiAvailabilityLight
. At least I was able to compile it.
Upvotes: 9