Google Places API for Android Error: Status{statusCode=NETWORK_ERROR, resolution=null}
Himanshu is right; it happens to me as well I wanted to filter by cities and added:
AutocompleteFilter.create(Arrays.asList(
Place.TYPE_LOCALITY, Place.TYPE_ADMINISTRATIVE_AREA_LEVEL_3));
this result in Status{statusCode=NETWORK_ERROR, resolution=null}
Not all constant from Place
are available for filtering with AutocompleteFilter, only two are available on Android: Place.TYPE_GEOCODE
and Place.TYPE_ESTABLISHMENT
('address' appear in documentation but not as constant in Place
)
Read carefully here:https://developers.google.com/places/supported_types#table3
If any other constant (e.g. Place.TYPE_LOCALITY
) are used the request will result in a confusing status error.
Please ensure the folowing.
1. The package name given in console registration page is same as that of actvity/fragment we are using. ie; if are using this auto search button inside com.example.rajeesh.UI.fragements.SearchFragment,
then inside console registration page package name should be
com.example.rajeesh.UI.fragements
This is different from the package name we given in manifest file.
2. Inside manifest please change
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_api_key" />
to
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_api_key" />
3. Enable Google Places API for Android in console page.
You can put null
instead of AutocompleteFilter property in getAutocompletePredictions
method if you want to get predictions of any types.