8

I want to use Google places API but I can't sync the project with "com.google.android.libraries.places:1.0.0:" dependency. How to add the places in my project?.

Manohar
  • 22,116
  • 9
  • 108
  • 144

3 Answers3

29

The library in documentation is wrong I guess, use this, it works. I had same issue few days back , gave a feedback to them on documentation they still didn't fix it.

implementation 'com.google.android.libraries.places:places:2.1.0'

You can see how to add places autocomplete over here

Edit: Seems like they finally fixed the documentation

jpthesolver2
  • 1,107
  • 1
  • 12
  • 22
Manohar
  • 22,116
  • 9
  • 108
  • 144
  • I'm trying with the same but i'm still getting could not resolve error :( do i need to change anything else? – madroid Feb 26 '19 at 07:41
  • Try adding `maven { url "https://maven.google.com" }` in project level `build.gradle` below jcentre() – Manohar Feb 26 '19 at 12:38
  • added it already but it is still giving the same error, it says sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target – madroid Feb 27 '19 at 09:34
  • can you add your build.gradle file , both project and app one – Manohar Feb 27 '19 at 09:39
  • 1
    please help me to list places in to recycleview ? –  Feb 27 '19 at 12:43
  • Its easier to use their default intent launcher/ fragment instead of populating on recyclerview , Try implementing first using [documentation](https://developers.google.com/places/android-sdk/autocomplete) If you are having any problem then I will help – Manohar Feb 27 '19 at 13:04
  • com.google.android.libraries.places.widget.AutocompleteActivity}: java.lang.IllegalStateException: Places must be initialized. –  Feb 28 '19 at 05:52
  • Actually i need for list near atm or hotels with user specified coverage. can you help me with that ? –  Feb 28 '19 at 05:54
  • add this line `Places.initialize(getApplicationContext(), "GOOGLE_API_KEY")` – Manohar Feb 28 '19 at 06:45
  • Worked like a charm! Thank you. – Taslim Oseni Oct 01 '20 at 21:01
  • That helped, thanks! Current version of places library is 2.5 – Liker777 Mar 27 '22 at 18:19
1

try to change

compileOnly "com.facebook.react:react-native:+"

by

api "com.facebook.react:react-native:+"
0

I also stuck with the same issue, now i removed this issue. According to google, "The v1.0.0 release of the Places SDK for Android introduces an all-new static library with updated functionality. The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019."

Add following dependency it will work...

implementation 'com.google.android.libraries.places:places:1.0.0'

For more information you can visit, https://developers.google.com/places/android-sdk/client-migration