I was having the same problem but i have been able to fix it.
The problem is that 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.
And if you check under the google API console, it only have the PLACES API and there is nothing like PLACES SDK FOR ANDROID anymore.
In the dependencies section of your app-level build.gradle file, add a dependency for the new SDK client library, as shown in the following example:
implementation 'com.google.android.libraries.places:places:1.0.0'
Then, you initialize it.
// Add an import statement for the client library.
import com.google.android.libraries.places.api.Places;
...
// Initialize Places.
Places.initialize(getApplicationContext(), apiKey);
// Create a new Places client instance.
PlacesClient placesClient = Places.createClient(this);
Programmatic autocomplete
The following changes were made to autocomplete:
PlaceAutocomplete is renamed to Autocomplete.
PlaceAutocomplete.getPlace is renamed to Autocomplete.getPlaceFromIntent.
PlaceAutocomplete.getStatus is renamed to Autocomplete.getStatusFromIntent.
PlaceAutocomplete.RESULT_ERROR is renamed to AutocompleteActivity.RESULT_ERROR (error handling for the autocomplete fragment has NOT changed).
If you are using the autocomplete widget like my case you can use this.
<fragment
android:id="@+id/autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name=
"com.google.android.libraries.places.widget.AutocompleteSupportFragment"
/>
Then initialize places
/**
* Initialize Places. For simplicity, the API key is hard-coded. In a production
* environment we recommend using a secure mechanism to manage API keys.
*/
if (!Places.isInitialized()) {
Places.initialize(getApplicationContext(), "YOUR_API_KEY");
}
// Initialize the AutocompleteSupportFragment.
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
Log.i(TAG, "Place: " + place.getName() + ", " + place.getId());
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Log.i(TAG, "An error occurred: " + status);
}
});
Check here for more information
Migrating to the New Place SDK
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…