Import Google Play Services Library in Android Studio

Import Google Play Services library in Android Studio

Try this once and make sure you are not getting any error in project Structure saying that "ComGoogleAndroidGmsPlay not added"

Open File > Project Structure and check for below all. If error is shown click on Red bulb marked and click on "Add to dependency".

GMS dependency

This is a bug in Android Studio and fixed for the next release(0.4.3)

Android Studio Google-play-services library

In order to use that artifact, you need to install the "Google Repository" in the extras of the SDK manager, not "Google Play Services" as it sounds like you've done.

Getting error when import Google Play services errors in Android Studio

Based from Setting Up Google Play Services:

To develop an app using the Google Play services APIs, you need to set up your project with the Google Play services SDK. If you haven't installed the Google Play services SDK yet, go get it now by following the guide to Adding SDK Packages.

Here are the steps to make the Google Play services API available to your app in Android Studio:

1. Open the build.gradle file inside your application module directory.

Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. Be sure to edit the file for your application module. See Building Your Project with Gradle for more information about Gradle.

2. Add a new build rule under dependencies for the latest version of play-services. For example:

apply plugin: 'com.android.application'
...

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

Be sure you update this version number each time Google Play services is updated.

3. Save the changes and click Sync Project with Gradle Files in the toolbar.

You can now begin developing features with the Google Play services APIs.

For additional information, you may also visit the following links:

  • Gradle Plugin User Guide
  • Android Studio with Google Play Services
  • eclipse android can not import google play services library

How to add Google Play services to my Eclipse ADT project

I implemented the solution that Andrew S provided at Missing "<sdk>/extras/google/google_play_services/libproject" folder after update to revision 30. First, I downloaded https://dl-ssl.google.com/android/repository/google_play_services_8298000_r28.zip. That means that instead of the Google Play services, revision 39 that I was trying to use, I went to the older revision 28.

I extracted the file and placed it at C:\Users\jaimemontoya\android-sdks\extras\google\google-play-services:

Sample Image

From Eclipse I used File > Import... > Android > Existing Android Code Into Workspace > Root Directory: C:\Users\jaimemontoya\android-sdks\extras\google\google-play-services\libproject\google-play-services_lib

I confirmed everything looked correct:

Project to import: C:\Users\jaimemontoya\android-sdks\extras\google\google-play-services\libproject\google-play-services_lib
New Project Name: google-play-services_lib

Then from the Eclipse Package Explorer I right-clicked my project, went to Properties, after that clicked Android and finally after scrolling down I used the "Add..." button to add the google-play-services_lib library. It will appeared as one of the added libraries:

Sample Image

The error is fixed for me now:

Sample Image

Adding Google Play Services to gradle (Android Studio) does not work

I don't think version 27.0.0 exists the most recent version is 8.1.0



Related Topics



Leave a reply



Submit