build.gradle
file inside your application module directory.build.gradle
file and a build.gradle
file for each module. Be sure toedit the file for your application module. SeeBuilding Your Project with Gradle for more information about Gradle.dependencies
for the latest version ofplay-services
, using one of the APIs listed below.build.gradle
contains a reference to the google()
repo or to maven { url 'https://maven.google.com' }
.build.gradle
file.play-services
target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.build.gradle
descriptions.API | Description in build.gradle |
---|---|
Google+ | com.google.android.gms:play-services-plus:17.0.0 |
Google Account Login | com.google.android.gms:play-services-auth:17.0.0 |
Google Actions, Base Client Library | com.google.android.gms:play-services-base:17.1.0 |
Google Sign In | com.google.android.gms:play-services-identity:17.0.0 |
Google Analytics | com.google.android.gms:play-services-analytics:17.0.0 |
Google Awareness | com.google.android.gms:play-services-awareness:17.1.0 |
Google Cast | com.google.android.gms:play-services-cast:17.1.0 |
Google Cloud Messaging | com.google.android.gms:play-services-gcm:17.0.0 |
Google Drive | com.google.android.gms:play-services-drive:17.0.0 |
Google Fit | com.google.android.gms:play-services-fitness:18.0.0 |
Google Location and Activity Recognition | com.google.android.gms:play-services-location:17.0.0 |
Google Mobile Ads | com.google.android.gms:play-services-ads:18.3.0 |
Mobile Vision | com.google.android.gms:play-services-vision:19.0.0 |
Google Nearby | com.google.android.gms:play-services-nearby:17.0.0 |
Google Panorama Viewer | com.google.android.gms:play-services-panorama:17.0.0 |
Google Play Game services | com.google.android.gms:play-services-games:19.0.0 |
SafetyNet | com.google.android.gms:play-services-safetynet:17.0.0 |
Google Pay | com.google.android.gms:play-services-wallet:18.0.0 |
Wear OS by Google | com.google.android.gms:play-services-wearable:17.0.0 |
build.gradle
build.gradle
properties for ProGuard use.To use ProGuard with Android Studio, you must enable the ProGuard setting in yourbuild.gradle
buildTypes
. For more information, see theProGuard guide.isGooglePlayServicesAvailable()
method. You get a reference to the singleton object that provides this methodusing GoogleApiAvailability.getInstance()
.You might call this method in theonResume()
method ofthe main activity. If the result code isSUCCESS
, then the Google Playservices APK is up-to-date and you can continue to make a connection. If, however, the result codeis SERVICE_MISSING
,SERVICE_VERSION_UPDATE_REQUIRED
,or SERVICE_DISABLED
,then the user needs to install an update. In this case, call thegetErrorDialog()
method and pass it the result error code. The method returns aDialog
youshould show, which provides an appropriate message about the error and provides an action thattakes the user to Google Play Store to install the update.