Geocoder.getFromLocation grpc failed on Android real device

前端 未结 9 619
故里飘歌
故里飘歌 2020-12-14 17:14

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

9条回答
  •  离开以前
    2020-12-14 17:49

    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()
    

提交回复
热议问题