In Eclipse, if we want to add Google Play Services to a project, we’ll simply import the play services project to workspace and add it as a library project. But in Android Studio, if you want to add play services, follow below steps.

Open your project’s build.gradle file and add below line under dependencies module. This will add all the Play Services APIs to your project.

dependencies {
    compile 'com.google.android.gms:play-services:7.0.0'
}

You can also selectively add the play services APIs which are necessary to your project.

The below will be add Google Analytics and Maps modules to your app.

dependencies {
    compile 'com.google.android.gms:play-services-base:7.0.0'
    compile 'com.google.android.gms:play-services-analytics:7.0.0'
    compile 'com.google.android.gms:play-services-maps:7.0.0'
}

Here you can find list of individual APIs play services supports.

Author

Ravi is hardcore Android programmer and Android programming has been his passion since he compiled his first hello-world program. Solving real problems of Android developers through tutorials has always been interesting part for him.

  • kunjan

    nice thanks

  • Sanjay

    Thnaks so much

  • Jeet Singh

    It can be done via selecting the module, then press f4. It will open the project properties. It will show you all the modules present in the present workspace. Select the project and click the dependency tab. Click the + – symbol as per your need to add / delete the dependency. You can set the sdk location, jdk location as well.

    • Jessica

      Great !

      Thanks,

      Jessica (www.becomeceleb.com?MyProfile)

  • Suresh Bora

    @Jeet Singh Nice Trick Thanks

  • Thava Selvan

    i saw two folder which one

    This is 1st (build.gradle(Project Maps))

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
    repositories {
    jcenter()
    }
    dependencies {
    classpath ‘com.android.tools.build:gradle:1.3.0’

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    }

    ————————————————————————————————————————-
    This is 2nd one(build.gradle(Module App))
    apply plugin: ‘com.android.application’

    android {
    compileSdkVersion 23
    buildToolsVersion “23.0.2”

    defaultConfig {
    applicationId “com.thavam.maps”
    minSdkVersion 23
    targetSdkVersion 23
    versionCode 1
    versionName “1.0”
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
    }
    }
    }

    dependencies {
    compile fileTree(dir: ‘libs’, include: [‘*.jar’])
    }
    allprojects {
    repositories {
    jcenter()
    }
    }

  • Vishvambhar

    I cant add this
    Show Error Like

    Error:(29, 13) Failed to resolve: com.google.android.gms:play-services:8.4.0

    Install Repository and sync project
    Show in File
    Show in Project Structure dialog

  • Tohin sarker

    im the new in android, can u tell me plz why i will Add Google Play Services to Android Studio Project

    • Mohammad Babul

      By adding google play service in Android project you can access Google services, such as Maps, Drive, and Google+. Once you have your apps set up to use these services, accessing them is typically straightforward @tohin_sarker:disqus

      • Tohin sarker

        thanks Babul vai

        • Mohammad Babul

          welcome tuhin sarkar

  • Santhosh Sapi

    Thanks a lot for the article. But i am facing some issue. Yesterday i started to port all my projects to Android Studio. I tried everything still GoogleCloudMessaging is having an error as ‘Cannot resolve symbol’.

    This is what i have.
    dependencies {
    compile ‘com.android.support:appcompat-v7:23.2.0’
    compile ‘com.google.android.gms:play-services:8.4.0’
    }

    Please help me in fixing this.

  • Leondre M

    Error:Execution failed for task ‘:app:processDebugManifest’.
    > Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [com.google.android.gms:play-services:7.0.0] C:AndroidAppFolderSourceSingleWeatherappbuildintermediatesexploded-aarcom.google.android.gmsplay-services7.0.0AndroidManifest.xml
    Suggestion: use tools:overrideLibrary=”com.google.android.gms.all” to force usage