1

When I click Places Auto complete fragment search box ,

I am getting the following error

 place fields must not be empty (9012) 

I already migrated to new places SDK . Also checked my Google Billing and Maps API. Everything is correct

My code

Places.initialize(getApplicationContext(),getResources().getString(R.string.google_api_key));

    placesClient = Places.createClient(this);

    AutocompleteSupportFragment placesfragment = (AutocompleteSupportFragment) getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);


    placesfragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {

        @Override
        public void onPlaceSelected(@NonNull Place place) {
            LatLng ll = place.getLatLng();

            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(ll, 14));

            if (manmarker != null) manmarker.remove();
            manmarker = mMap.addMarker(new MarkerOptions().position(ll).title("Manually Selected Location"));
            manapprox = getAddressFromLatLAng(ll);
            manualaddr.setText(manapprox);
            manlatlng = ll;
        }

        @Override
        public void onError(Status status) { // Handle the error
            Toast.makeText(MapsActivity.this, "Something went wrong! please try again "+status.getStatusCode() + " " + status.getStatusMessage() + Places.isInitialized(), Toast.LENGTH_SHORT).show();
        }
    });

Please Help me to resolve this issue

RagAnt
  • 1,064
  • 2
  • 17
  • 35

1 Answers1

1

Try specifying the types of place data to return using setPlaceFields:

placesfragment.setPlaceFields(listOf(Place.Field.ID, Place.Field.NAME));

Reference here.

evan
  • 5,443
  • 2
  • 11
  • 20