title: Import Google Play Services library in Android Studio
body: <p>I have an Android project that has been developed entirely within Android Studio (currently version 4.2, gradle version 1.9-all). I want to add functionality from Google Play Services.</p>
  <p>The project is unable to resolve <code>GooglePlayServicesUtil</code>, and when I enter the import manually (shown below), I get <code>Cannot resolve symbol 'common'</code>.</p>
  <pre><code>import com.google.android.gms.common.GooglePlayServicesUtil;
  </code></pre>
  <p>Any idea what I need to do to get <code>GooglePlayServicesUtil</code> to resolve?</p>
  <h2>What I've Tried</h2>
  <p>From the <a href="http://developer.android.com/google/play-services/setup.html" rel="noreferrer">Google Play Services Setup</a> it looks like I just have to add the <code>com.google.android.gms:play-services:4.+</code> dependency to my <code>build.gradle</code> file (and resync project files with gradle) to make the SDK available to my project. I do get an &quot;exploded bundle&quot; in <code>ProjectName/module/build/exploded-bundles</code>, but that doesn't seem like it does the trick.</p>
  <p>I have Google Play Services, Android Support Repository and Google Repository installed from the SDK Manager already. I've also deleted and reinstalled them multiple times :)</p>
  <p>Edit:</p>
  <p>Might I need to manually add google_play_services as a Project/Global Library? I've attempted with no success.</p>
  <p>I'm trying to verify that I'm developing against the Platform API with Google Services (if that's even possible), but I'm not sure that's the case. Nothing I change seems to do anything.</p>
  <p>The External Libraries of my project shows:</p>
  <ul>
  <li>&lt; Android API 19 Platform &gt;</li>
  <li>&lt; 1.7 &gt;</li>
  <li>joda-time-2.3</li>
  <li>support-v4-13.0.0</li>
  </ul>
  <h2>Source Code</h2>
  <p>This is my ProjectName/module/build.gradle file:</p>
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.7.+'
      }
  }
  
  apply plugin: 'android'
  
  repositories {
      mavenCentral()
  }
  
  android {
      compileSdkVersion 19
      buildToolsVersion '19.0.1'
      defaultConfig {
          minSdkVersion 17
          targetSdkVersion 19
          versionCode 1
          versionName &quot;1.0&quot;
      }
      buildTypes {
          release {
              runProguard true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
      }
      signingConfigs {
      }
      productFlavors {
      }
  }
  
  dependencies {
      compile 'com.google.android.gms:play-services:4.+'
      compile 'joda-time:joda-time:2.3@jar'
  }
  </code></pre>
  <p>The <code>com.google.android.gms.version</code> number resolves fine in my manifest. Here is my ProjectName/module/src/main/AndroidManifest.xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.android&quot; &gt;
  
      &lt;uses-sdk android:minSdkVersion=&quot;17&quot; android:targetSdkVersion=&quot;19&quot;/&gt;
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@drawable/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:theme=&quot;@style/AppTheme&quot; &gt;
          &lt;activity
              android:name=&quot;com.example.android.MainActivity&quot;
              android:label=&quot;@string/app_name&quot; &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=&quot;.SecondActivity&quot;/&gt;
  
          &lt;meta-data android:name=&quot;com.google.android.gms.version&quot;
              android:value=&quot;@integer/google_play_services_version&quot; /&gt;
  
          &lt;provider
              android:name=&quot;.DataProvider&quot;
              android:authorities=&quot;com.example.android.provider&quot; &gt;
          &lt;/provider&gt;
  
          &lt;receiver android:name=&quot;.WidgetProvider&quot; &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.appwidget.action.APPWIDGET_UPDATE&quot; /&gt;
              &lt;/intent-filter&gt;
              &lt;meta-data android:name=&quot;android.appwidget.provider&quot;
                     android:resource=&quot;@xml/widget_info&quot; /&gt;
          &lt;/receiver&gt;
  
          &lt;service android:name=&quot;.DatabaseService&quot; /&gt;
          &lt;service android:name=&quot;.WidgetProvider$UpdateService&quot; /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p>Here is my MainActivity, where I'm trying to check whether GooglePlayServices is Available:</p>
  <pre><code>package com.example.android;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  
  import com.google.android.gms.common.GooglePlayServicesUtil;
  
  public class MainActivity extends Activity {
      private static final String TAG = &quot;MainActivity&quot;;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      @Override
      public void onResume() {
          Log.i(TAG, &quot;onResume&quot;);
          GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
      }
  }
  </code></pre>