So I'm using Google Maps in my Android app for a c...
# android
y
So I'm using Google Maps in my Android app for a country picker but I keep getting this error:
Java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
How can I prevent this kind of error? I think the problem comes from here:
Copy code
val address = geocoder.getFromLocation(it.latitude, it.longitude, 1)
val country = address[0].countryCode.toLowerCase()
f
Copy code
address.gerOrNull[0]?.countryCode?.toLowerCase().orEmpty()

val country = if (address.isNotEmpty()) address[0].countryCode.toLowerCase() else ""
either one of those