title: How to use Google Play Services from an Android Library in Android Studio
body: <p>I am developping an Android library in Android Studio that needs to use the Google Play Services. It already uses several other jar libraries, and everything works well when my library is used in an android application project.</p>
  
  <p>According to the official Android documentation, I should import the Google Play Services with gradle (<a href="http://developer.android.com/google/play-services/setup.html" rel="nofollow">http://developer.android.com/google/play-services/setup.html</a>). But if I import it that way, when I use my library in an android application (by importing the .aar generated by Android Studio), it just hangs as soon as <code>GooglePlayServicesUtil.isGooglePlayServicesAvailable</code> is called, with absolutely no log shown in Logcat. So my guess was that I need to import the Google Play Services as a jar instead of in the gradle.build file. Here is the gradle.build file I use :</p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.6.+'
      }
  }
  apply plugin: 'android-library'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      //compile 'com.google.android.gms:play-services:4.3.23'  //works in my lib, but not my app using the lib
      compile fileTree(dir: 'libs', include: '*.jar')
  }
  
  android {
      compileSdkVersion 19
      buildToolsVersion '19.0.1'
  
      defaultConfig {
          minSdkVersion 9
          targetSdkVersion 19
      }
      release {
          runProguard false
      }
  }
  </code></pre>
  
  <p>And I have this is my lib's manifest :</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="novom.anyware.anywaresdk"
      android:versionCode="1"
      android:versionName="0.1.0"&gt;
  
      &lt;uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:label="@string/app_name"
          android:icon="@drawable/ic_launcher"&gt;
          &lt;service ... /&gt;
          &lt;receiver ... /&gt;
          &lt;receiver android:name="novom.anyware.anywaresdk.AWRGeofencesReceiver" /&gt;
          &lt;service ... /&gt;
          &lt;receiver ... /&gt;
          &lt;meta-data android:name="com.google.android.gms.version" android:value="4323000" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The problem here is that I cannot use the Google Play Services as a jar library, because I don't have the resources linked to it :</p>
  
  <pre><code>04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3086 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x004b
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3082 (common_google_play_services_enable_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0056
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3097 (common_google_play_services_update_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0061
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3094 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0073
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3090 (common_google_play_services_network_error_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0085
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3088 (common_google_play_services_invalid_account_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x00af
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3094 (common_google_play_services_unsupported_title) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x00ce
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3083 (common_google_play_services_install_button) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x000f
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3080 (common_google_play_services_enable_button) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0016
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3095 (common_google_play_services_update_button) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x001d
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3091 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0007
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3085 (common_google_play_services_install_text_tablet) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0018
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3084 (common_google_play_services_install_text_phone) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0038
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3081 (common_google_play_services_enable_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x003f
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3096 (common_google_play_services_update_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0046
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3093 (common_google_play_services_unsupported_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0066
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3089 (common_google_play_services_network_error_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x006d
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3087 (common_google_play_services_invalid_account_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0074
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3092 (common_google_play_services_unsupported_date_text) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.867    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x007b
  04-09 17:43:51.877    9715-9828/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3091 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;
  04-09 17:43:51.877    9715-9828/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x000c
  04-09 17:43:51.877    9715-9828/foo.bar.myoldapp E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
  </code></pre>
  
  <p>I read a lot of post that tell to include the google-play-services_lib as a Module in my Android Library Project but every way I tried failed.</p>
  
  <p>Any suggestion please?</p>