Sharing my experience just in case it is useful to others... With latest android studio 2024, API 35, used below code to make it work.
Added .media to the path in the import statement.
import androidx.exifinterface.media.ExifInterface
As using exif.GetAttribute(ExifInterface.TAG_GPS_LATITUDE) returned zero, used exif?.latLong function to get the latitude and longitude values.
val latLong = exif?.latLong