0

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')

Kolopox
  • 276
  • 1
  • 4
  • 17

1 Answers1

2

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

ZeroOne
  • 8,996
  • 4
  • 27
  • 45
  • I have google play services version 39 and google repository version 46 as well but when I synchronize (with internet) without 'com.google.android.gms:play-services:10.2.1' all my import com.google.android arn't reconized – Kolopox Apr 28 '17 at 13:38
  • Yeah I tried it but same result :/ and with "compile 'come.google.android....'" I have a new error (I will post it an edit) – Kolopox Apr 28 '17 at 13:45
  • 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.. this must be working – ZeroOne Apr 28 '17 at 13:48
  • ah.. i see your problem.. like i said 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 still want to use it, please enable multidex `multiDexEnabled true` inside defaultConfig in app/gradle – ZeroOne Apr 28 '17 at 13:58
  • What is individual dependencies ? I checked it but still don't understand what I must do to make it work fine ... – Kolopox Apr 28 '17 at 14:04
  • see this thread http://stackoverflow.com/questions/43407318/how-to-suppress-the-avoid-using-bundled-version-of-google-play-services-sdk-wa/43407421#43407421 – ZeroOne Apr 28 '17 at 14:08
  • I tried multiDexEnabled true but it didn't solve anything. So if I find the dependencies I need for my app in 'com.google.android.gms' I should be able to synch without any problem, is that right ? By the way thanks for the fast answer and helping me solving my problem :) – Kolopox Apr 28 '17 at 14:15