Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import Google Places PlacePicker into Android project

I'm attempting to write a simple program that involves using a PlacePicker to capture location information. My project, however, can't seem to resolve the necessary imports.

build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services-location:9.2.0'
    compile 'com.google.android.gms:play-services-maps:9.2.0'
}

Activity:

import com.google.android.gms.location.places.Place; // "Place" is not resolved
import com.google.android.gms.location.places.ui.PlacePicker; // "ui" is not resolved
import com.google.android.gms.maps.model.LatLng;

The LatLng import seems to work, but not the other two. The whole project runs fine when I import the full com.google.android.gms:play-services:9.2.0 API, but I want to use specific API calls to cut back on unnecessary libraries.

like image 799
Fawfulcopter Avatar asked Jun 27 '16 21:06

Fawfulcopter


1 Answers

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.

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

It's been answered here

like image 132
Miguel Avatar answered Sep 24 '22 08:09

Miguel