Kolopox
Kolopox

Reputation: 408

compile google play service

I know this question is really simple for the persons experimented with android but please help me. I followed this tutorial : https://examples.javacodegeeks.com/android/android-location-api-using-google-play-services-example/ to the latitude and longitude of my device.

My problem is this part :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile "com.google.android.gms:play-services:8.3.0"
}

I tried to do the same with my own code :

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-service:8.3.0'
testCompile 'junit:junit:4.12'
}

but when I synchronize the project I get this error :

fail to resolve:com.google.android.gms:play-service:8.3.0

So in my SDK manager I downloaded the google play service but here's my problem : How can I check the version of my 'com.google.android.gms:play-service' ???

EDIT :

The version I searched for was 10.2.1 If you have the same problem check File->Project Structure->Dependencies->'+' and check version. It works on AVD now but with it you have a new error :

My gradle.build (app)

manifest

with error : enter image description here

EDIT 2 : if you have the same error check https://developers.google.com/android/guides/setup and select what you want (exemple compile 'com.google.android.gms:play-services-location:10.2.1')

Upvotes: 0

Views: 5182

Answers (1)

ZeroOne
ZeroOne

Reputation: 9117

Make sure you connected to internet while sync gradle. its only for first time to download the gradle.

Make sure install/update latest Google Repository and Google Play Services in SDK Manager

enter image description here



Avoid using compile 'com.google.android.gms:play-services:10.2.1' because it is terribly heavy and cause Dex problem. use individual dependencies instead. If you insist want to use it, enable multiDexEnabled true

enter image description here


If you are using Google Firebase, dont forget to add classpath 'com.google.gms:google-services:3.0.0' then add this apply plugin: 'com.google.gms.google-services' at the bottom of the app/build.gradle

P/s: Please invalidate/cache and restart AS

Upvotes: 2

Related Questions