23

Declaring dependencies as

compile 'com.google.firebase:firebase-messaging:9.4.0'

I get "can not resolve symbol GoogleApiAvailability" message in the activity's import row

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

What is wrong?

  • not question's duplicate: Google Play Services are already on the latest version
GPack
  • 2,494
  • 4
  • 19
  • 50
  • Possible duplicate of [import com.google.android.gms.common.api.GoogleApiClient; cannot be resolved](http://stackoverflow.com/questions/28262213/import-com-google-android-gms-common-api-googleapiclient-cannot-be-resolved) – hrskrs Sep 20 '16 at 06:00
  • check Android Support Repository in sdk is latest ?? – Vishal Patoliya ツ Sep 20 '16 at 06:00
  • Android Support Repository is rev.38. Google Play Services and Google Repository are rev.32. – GPack Sep 20 '16 at 06:07

4 Answers4

37

Add this line to your build file dependencies:

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

play-services-base is the Play Services base client library and is listed in the Play Services Setup Guide.

Bob Snyder
  • 37,759
  • 6
  • 111
  • 158
5

I faced same problem but in my case problem solved by just changing the position of apply plugin: 'com.google.gms.google-services' in the build.gradle(Module: app) file.

Line

apply plugin: 'com.google.gms.google-services'

was written at the last in the gradle file. Remove this from here and add it to the top, below the line apply plugin: 'com.android.application' Like this:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

and click on sync now. Problem solved.

Rahul Sharma
  • 5,949
  • 5
  • 36
  • 46
  • 2
    Moving the plugin line to the top might lead to problems of inconsistencies between dependency versions. That's why it is suggested to put it at the bottom, as stated here: https://developers.google.com/android/guides/google-services-plugin -> "This step requires that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file so that no dependency collisions are introduced." – Elementary Jun 16 '17 at 10:35
3

For my case just adding this dependency worked -

implementation "com.google.android.gms:play-services-location:16.0.0
Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
1

If your using the latest classpath 'com.google.gms:google-services:4.3.10', for checking the Google PlayServices Availability you can use GoogleApiAvailabilityLight

Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73