Reputation: 2069
I am trying to implement a autocomplete places search following this article.
http://www.truiton.com/2015/04/android-places-api-autocomplete-getplacebyid/
I have followed all steps, and also added proper dependencies in my build.gradle file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Also here are the meta data section in my manifest.
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
also I have all the required SDK components installed. Still my android studio can not resolve the places part in the following imports:
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.AutocompletePrediction;
import com.google.android.gms.location.places.AutocompletePredictionBuffer;
import com.google.android.gms.location.places.Places;
this is how they look as they can not find the Places part.
How can I resolve this issue? I am using SDK 19 for my app.
Upvotes: 23
Views: 40471
Reputation: 11
I was also faced with the same issue recently and adding this
implementation 'com.google.android.gms:play-services-places:11.4.0'
to my dependency under build.gradle
(app) file solves the problem for me.
NB: make sure the version of your dependencies are all thesame if not you will encounter or errors
Upvotes: 0
Reputation: 2448
In play-services 9.2.0 the places API is no longer located in location. Those are now in their own places dependency. To resolve those you should add this to your build.gradle.
compile 'com.google.android.gms:play-services-places:9.2.0'
check out
Places class is removed from android play services 9.2.0
Upvotes: 26
Reputation: 583
Add following two dependencies in your build.gradle(Module: app)
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
Upvotes: 7
Reputation: 200080
The Places API was only added in Google Play services 7.0: you'll need to update your dependency to be at least 7.0.0
, although the latest as of this answer is 15.0.0
.
Note in almost every case, you should use selective APIs to only include the portions of Google Play services you need. In that case, you'd actually use a dependency such as
implementation 'com.google.android.gms:play-services-location:15.0.0'
Upvotes: 14
Reputation: 80
For latest versions of google play services for location changes have been made. Check [Selective Google Play Services API not finding classes
Upvotes: 0
Reputation: 760
Since Play Services version 9.2 we should add the following dependancy to access Google Places API.
compile 'com.google.android.gms:play-services-places:11.0.2'
The latest version at the time of this writing.
The accepted answer for this thread was outdated.
Upvotes: 8
Reputation: 402
compile 'com.google.android.gms:play-services-location:7.5.0'
Just add it in your dependency (build.gradle [Module:Application]) Then file -> Invalidate caches/restart-> invalidate and Restart
Upvotes: 0
Reputation: 556
try including compile 'com.google.android.gms:play-services-places:10.2.0'
Upvotes: 5
Reputation: 4998
Add compile 'com.google.android.gms:play-services-places:<version>
, where <version>
is perhaps at least: 9.2.1
under dependencies
in your modules's build.gradle
Upvotes: 49