PlaceAutocompleteFragment can't resolved

后端 未结 1 1851
悲&欢浪女
悲&欢浪女 2021-01-13 15:34

In my app I have added Google Maps and they work fine. I want to add a PlaceAutocompleteFragment. I am using the key which I had already generate for maps and I have enable

相关标签:
1条回答
  • 2021-01-13 16:31

    The problem here is that PlaceAutocompleteFragment didn't exist in version 8.3 of Google Play Services.

    This isn't documented very well, but you can see on this blog that PlaceAutocompleteFragment was "announced" in December 2015.

    You can also see in the PlaceCompleteFragment Google code samples on GitHub that they are using version 8.4 of GooglePlayServices.

    I also had this problem, and updating Google Play Services is what made it work.

    So, update Google Play Services in the SDK Manager, and then modify the build.gradle like so, and it should work:

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

    Update

    In newer versions of Google Play Services, they have broken out the Google Places API, so you need to include it in addition to Maps and Location:

    compile 'com.google.android.gms:play-services-maps:11.0.2'
    compile 'com.google.android.gms:play-services-location:11.0.2'
    compile 'com.google.android.gms:play-services-places:11.0.2'
    
    0 讨论(0)
提交回复
热议问题