21

How can I make the PlaceAutocompleteFragment resolved?

I am trying to use the new PlaceAutocompleteFragment. I try to use the following code:

<fragment
  android:id="@+id/place_autocomplete_fragment"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
  />

This code sample is just a copy. It is from this site. However PlaceAutocompleteFragment is unresolved in my case. How can I fix this issue? I think the solution must be very easy. However I have been looking for quite some time.

peterh
  • 11,875
  • 18
  • 85
  • 108
Gilian
  • 1,539
  • 2
  • 15
  • 27

4 Answers4

66

For uses of PlaceAutocompleteFragment we need to add one lib in gradle add this

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

in your gradle of Android Application.I have checked this in my Android studio. Please let me know if your problem is solved.

Check version (16.0.0 at the time of writing) of play-services here.
(From the comment below)

leonardkraemer
  • 6,573
  • 1
  • 31
  • 54
Mahesh Giri
  • 1,810
  • 19
  • 27
3

Just change your compile library in gradle from "locations" to "places"

for example

change

compile 'com.google.android.gms:play-services-location:"yourversion"'

to

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

1

You need to add one lib in gradle add this

compile 'com.google.android.gms:play-services-location:10.0.1'

use same version "10.0.1" or what you have currenty in your gradle in both services.

Example:-

compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
Abhishek Kumar
  • 1,255
  • 13
  • 21
1

used implementation 'com.google.android.gms:play-services-places:16.0.0' but still was facing problem with 'PlaceAutocompleteFragment'

Need to add

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

Shashank Bhong
  • 238
  • 3
  • 5