react-native-geocoder-reborn
react-native-geocoder-reborn copied to clipboard
Type mismatch: inferred type is (Mutable)List<Address!>? but MutableList<Address> was expected
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"
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)
I think it would be great to make a PR for this?
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",
...
}
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.
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>