react-native-geocoder-reborn icon indicating copy to clipboard operation
react-native-geocoder-reborn copied to clipboard

Type mismatch: inferred type is (Mutable)List<Address!>? but MutableList<Address> was expected

Open Haseeba393 opened this issue 2 years ago • 5 comments

I'm using this library to fetch locations names, but while building on Android side it is giving me this error: Type mismatch: inferred type is (Mutable)List<Address!>? but MutableList<Address> was expected

Here is my environment "react-native": "0.69.1" "@timwangdev/react-native-geocoder": "^1.0.0-alpha.7"

Haseeba393 avatar Oct 07 '22 07:10 Haseeba393

It happened to me while trying to compile with SDK 33.

The error comes from GeocoderModule.kt:45

[...]
if (swLat != null && swLng != null && neLat != null && neLng != null) {
    addresses = geocoder.getFromLocationName(addressName, maxResults, swLat, swLng, neLat, neLng)
} else {
    addresses = geocoder.getFromLocationName(addressName, maxResults)
}
[...]

However, no problems when using SDK 32. That's because the "Geocoder.getFromLocationName" method has been deprecated in API 33 : Geocoder.getFromLocationName (old) and has been replaced with this one Geocoder.getFromLocationName (new)

gaelhuot avatar Oct 20 '22 13:10 gaelhuot

I think it would be great to make a PR for this?

Haseeba393 avatar Oct 20 '22 13:10 Haseeba393

I made a fork including a quick-fix for API 33 only until I make something cleaner for a pull-request https://github.com/gaelhuot/react-native-geocoder-reborn

"dependencies": {
    ...
    "@timwangdev/react-native-geocoder": "https://github.com/gaelhuot/react-native-geocoder-reborn",
    ...
}

gaelhuot avatar Oct 21 '22 13:10 gaelhuot

Just passing by to thank you @gaelhuot , that was really helpful! Since this one is no longer maintained, at least I can patch-package the change you provided.

pierroo avatar Dec 26 '22 15:12 pierroo

I was able to solve with SDK 33 in this way:

File: GeocoderModule.tk

line 46 - addresses = geocoder.getFromLocationName(addressName, maxResults, swLat, swLng, neLat, neLng) as MutableList<Address>

line 48 - addresses = geocoder.getFromLocationName(addressName, maxResults) as MutableList<Address>

brazzoduro26 avatar Jul 06 '23 19:07 brazzoduro26