0

I am trying to add google play service to my project but it gives me error when I try to edit build (Gradle).

enter image description here

How can I fix it?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Saleh923
  • 105
  • 8

4 Answers4

1

In your configuration there some issues.

  • You are using the wrong build.gradle file.
    It is your top-level file. You should add this line in your app/build.gradle

  • There is a typo. You are missing the ' at the end of the line compile.

  • Use an updated version.

For example use:

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

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

Finally refer this official doc for more info.

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

For example if you need to make only your app aware of location updates add compile 'com.google.android.gms:play-services-location:8.1.0' only in gradle or if you need only map choose compile 'com.google.android.gms:play-services-maps:8.1.0'.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I had these do i have to remove them and keep only play service? dependencies {compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1' } – Saleh923 Nov 04 '15 at 07:19
  • @Saleh923 Refer this answer. There are 2 build.gradle file in your project. You are using the wrong file to add the dependencies. http://stackoverflow.com/questions/23241681/why-are-there-two-build-gradle-files-in-an-android-studio-project/23241888#23241888 – Gabriele Mariotti Nov 04 '15 at 07:37
1

Please replace

compile 'com.google.android.gms:play-services:3.1.36

with

compile 'com.google.android.gms:play-services:3.1.36'

Arjun
  • 736
  • 1
  • 8
  • 24
Mayuri Joshi
  • 164
  • 1
  • 2
  • 12
0

One thing you can try is Right Click on app open module settings on Dependencies Tab click '+' icon and add there 'com.google.android.gms:play-services:8.1.0' and click search icon and add that dependency,

Vishavjeet Singh
  • 1,385
  • 11
  • 13
0

So i don't want to elaborate what you had done wrong as my colleagues figured it out.I like to say, while playing with Google Play Service

Selectively compile APIs into your executable

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

For example if you need to make only your app aware of location updates add compile 'com.google.android.gms:play-services-location:8.1.0' only in gradle or if you need only map choose compile 'com.google.android.gms:play-services-maps:8.1.0'.

Thank you.

Visit for more.

Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73