I'm using FusedLocationProviderClient in my app and it works fine to get user current location but suddenly I got this crash
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter location
here is how I define it inside my activity
private lateinit var fusedLocationClient: FusedLocationProviderClient
//
fusedLocationClient =
LocationServices.getFusedLocationProviderClient(this)
// the crash happens on the next code on (addOnSuccessListener)
fusedLocationClient.lastLocation
.addOnSuccessListener { location ->
lat = location.latitude
lng = location.longitude
goToLocationOnMap(LatLng(lat, lng))
}