Incompatible type error Geocoder Google API

时间:2016-07-19 01:22:07

标签: android google-maps google-geocoder

I am trying to use the geocoder API by google in Android.

Here's the code :

 private void getLatLong(String inputaddress) throws IOException {
        Geocoder mygeocoder = new Geocoder(this.getContext());
        List<Address> gclist = mygeocoder.getFromLocationName(inputaddress,1);
    }

However, I get an error:

Error: incompatible types: List<android.location.Address> cannot be converted to List<com.google.android.gms.identity.intents.Address>

While declaring the List, I am making sure that it is importing from the com.google.android.gms.identity.intents.Address , still I am getting this error. Any idea where am I going wrong? Thank you.

1 个答案:

答案 0 :(得分:3)

这完成了工作

List<android.location.Address> gclist ;
        gclist  = mygeocoder.getFromLocationName(inputaddress,1);