I need to get the city and state from latitude and longitude. Geocoder does this function to get the city and state. But I am getting an error java.io.IOException: grp
It is a reported bug in Android, check @xomena answer for the link.
Alternately, you can use the web services. Add this to gradle dependencies:
api 'com.google.maps:google-maps-services:0.10.2'
Sample code to get addresses:
val geoApiCtx = GeoApiContext.Builder()
.apiKey(Util.readGoogleApiKey(ctx))
.build()
val addresses = GeocodingApi.reverseGeocode(geoApiCtx, loc).await()