-1

I am attempting to migrate to the new places SDK. I have successfully added all the libraries to my app-level build.gradle, and updated my XML fragment. However, the code implementation to initialize the AutocompleteSupportFragment has multiple unresolved errors. I have tried everything I can to no avail. please help

I am quite new to programming. I tried following the steps here http://errorstrike.com/2019/02/places-autocomplete-error-fix-2019/#respond it did not resolve any of my issues.

isInitialized() cannot be resolved.

Cannot resolve symbol 'Field' and

TAG has private access- I followed this 'TAG' has private access in 'android.support.v4.app.FragmentActivity'

Then got another error saying :setOnPlaceSelectListner in AutocompleteSupportFragment cannot be applied to (anonymous com.google.android.gms.location.places.ui.PlaceSelectionListner).

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);
            }
        });

I expected my google search to work as usual but it is still not able to read my places API. I get this error with the old places SDK (Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED,resolution=null})

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Ken
  • 41
  • 4

1 Answers1

3

This is now resolved. The issue and solution is below:

the issue, I had the wrong implementation in my app level gradle

implementation 'com.google.android.libraries.places:places-compat:1.0.0'

solution remove compat implementation 'com.google.android.libraries.places:places:1.0.0'

Ken
  • 41
  • 4