Add Google Play service to an Android library project in Android studio

1.7k Views Asked by At

I have a library project FooLib which uses Google play service (location service). When I was using Eclipse, I have google-play-services-lib (also as a library project) in my workspace and I include it in FooLib, and everything is working fine. Now I am migrating to Android studio and I could not figure out a way to include Google play service in a library project. Here is what I have done so far:

  1. Installed Google player service, Google Repository in the SDK manager. (I am using the latest Android studio 1.0.1)

enter image description here
2. Added compile 'com.google.android.gms:play-services:6.5.+' to the build.gradle file for FooLib under dependencies. Sync the gradle file. Here is my guild.gradle file

apply plugin: 'com.android.library'

android {  
    compileSdkVersion 21  
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {  
    compile 'com.google.android.gms:play-services:6.5.+'  
    compile files('libs/aws-android-sdk-1.5.0-core.jar')  
}
  1. The official doc (http://developer.android.com/google/play-services/setup.html) mentioned that I also need to add

    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

to the manifest as a child of <application> tag. But in the manifest file for a library project, there is no <application> tag. I tried without the meta-data tag or adding a dummy <application> tag in the manifest and attached meta-data tag to it. Neither case works.

I tried both AndroidManifest files below
enter image description here
Or
enter image description here

I am still getting
enter image description here

Does anybody know how to add Google play service to a library project in Android studio? Much appreciated!

0

There are 0 best solutions below