Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build fails looking for Google Play Services in Android Studio - is my SDK correct?

I have a question very similar to Gradle build fails looking for Google Play Services in Android Studio

I have a working android project but when I add

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

I get a gradle build error

Error:Failed to find: com.google.android.gms:play-services:5.2.8
<a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Open in Project Structure dialog</a>

I have added the SDKs through the manager. Other threads have suggested that there might be a second SDK library on the computer causing the issue, but I have not been able to resolve this. I am using a mac (and normally a PC user so please bear with me) and looking at the SDK manager and the project structure dialog both say the SDK is located at:

/Applications/Android Studio.app/sdk

Given they are pointing to the same place it must be some other cause of the error?

Maybe I have a version other than 5.2.8 (although unlikely, as andoid studio says this is the most up to date and I have just updated the SDK)? How can I check the version installed on my machine - its not in the file names?

like image 338
EnduroDave Avatar asked Aug 10 '14 13:08

EnduroDave


People also ask

What is Gradle build in Android Studio?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.


2 Answers

If you are going to use version 5.2.8 you have to set on your build.gradle

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

Because it is store on the directory :

ANDROID_SDK_PATH/extras/google/m2repository/com/google/android/gms/play-services/5.2.08

You can use '+' instead '08' and you will be using the last minor version

compile 'com.google.android.gms:play-services:5.2.+'
like image 174
Jc Miñarro Avatar answered Oct 21 '22 17:10

Jc Miñarro


OK so it looks as though my version number was off and thats all that was causing the problem. If anyone else has this issue check your version number in the AndroidManifest.xml file in the google_play_services_lib directory

like image 41
EnduroDave Avatar answered Oct 21 '22 16:10

EnduroDave