10

I haven't seen this problem anywhere on the internet, also it doesn't seem the library is deprecated, but I just can't add the import:

import com.google.android.gms.location.places.GeoDataClient;

My Android SDK is up to date.

Does anyone know how to use it? Or rather, another way to get my current location on GPS?

Thanks a lot.

Yago Dórea
  • 336
  • 1
  • 3
  • 12

6 Answers6

12

just add:

compile 'com.google.android.gms:play-services-places:11.2.0'

and

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

because GeoDataClient was added in 11.2.0 you can check this official document

Cœur
  • 37,241
  • 25
  • 195
  • 267
Xianwei
  • 2,381
  • 2
  • 22
  • 26
  • For newer version of gradle, higher than 4.1. You can use my answer instead https://stackoverflow.com/a/46371963/3940133 – HendraWD Sep 17 '18 at 16:26
6

Try to add

```gradle

compile 'com.google.android.gms:play-services-maps:11.2.0'
compile 'com.google.android.gms:play-services-places:11.2.0'
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.android.gms:play-services-location:11.2.0'

``` in build.gradle, then you may need add

```gradle

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

}

```

finally, Build -> rebuild project.

jiar wang
  • 360
  • 2
  • 12
  • aren't you just importing all google play services api at once? It will make your project big and reach 65k method limit easily – HendraWD Sep 22 '17 at 19:29
  • I mean that we just need `play-services-places`, so it will be safe to remove `play-services-maps`, `play-services` and `play-services-location` – HendraWD Jul 19 '18 at 15:43
  • I am aware this answer have some problem, but I can remember which `jar` contains `com.google.android.gms.location.places.GeoDataClient;`, so I suggest you to delete other `jar` . – jiar wang Sep 17 '18 at 06:10
1

Adding just this one dependency to apps build.gradle

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

and below code to project's build.gradle should work.

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Shree
  • 354
  • 2
  • 21
0

this link can help you.It's about using Geo location in android app https://www.toptal.com/android/android-developers-guide-to-google-location-services-api

0

@Xianwei's answer is working, but it is good to always improve our code over time, since there will always a new, better and simpler implementation. Basically it is more detail and improvement from @Xianwei's answer.

Add google() repository in your top-level build.gradle

allprojects {
    repositories {
        jcenter()
        google()

        // If you're using a version of Gradle lower than 4.1, you must instead use:
        // maven {
        //     url 'https://maven.google.com'
        // }
        // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}   

Add places google play service dependency in your app-level build.gradle

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // Your other dependencies...
    implementation 'com.google.android.gms:play-services-places:x.x.x'
}

Where x.x.x is the newest version of play-services-places, current working version is 15.0.1. You can check the newest version in the official documentation here

HendraWD
  • 2,984
  • 2
  • 31
  • 45
0

Add the following dependency in build.gradle

implementation 'com.google.android.gms:play-services-places:15.0.1'

Anbuselvan Rocky
  • 606
  • 6
  • 22