У меня есть журнал сбоев после минификации:
kotlin.KotlinNullPointerException
at com.package_name.SelectRaduisFragment.access$centerLocation(Unknown Source:97)
access$drawCircle
access$getErrorMessage
access$getErrorMessage
access$getRadiusPosition
access$getSeekBarPosition
access$getServices
access$getServices
access$setBackgroundTint
access$setCityId$p
access$setLatitude$p
access$setLocationListener$p
access$setLocationProvider$p
access$setRadiusChangedJob$p
access$showParametersFragment
access$showStationsCount
access$showUserLocation
addCircle
getCircleZoomValue
getCity
getErrorMessage
getErrorMessage
getServices
isLocationChanged
onActivityResult
onCreateView
onMapReady
onRequestPermissionsResult
setBackgroundTint
setClickListeners
showParametersFragment
showStationsCount
showUserLocation
at com.package_name.SelectRaduisFragment.access$getCityId$p(Unknown Source:19)
access$hideProgress
access$moveMapToLocation
access$selectRadius
access$setLongitude$p
access$setRegionId$p
access$setSeekBarPosition
access$showErrorDialog
drawCircle
getSeekBarPosition
showErrorDialog
at com.package_name.SelectRaduisFragment.access$centerLocation(Unknown Source:16)
access$drawCircle
access$getErrorMessage
access$getErrorMessage
access$getRadiusPosition
access$getSeekBarPosition
access$getServices
access$getServices
access$setBackgroundTint
... and so on
Как понять, где произошло NPE? С чего начать? Сверху или снизу списка? Как я понял, ошибка возникает в centerLocation
, но не может быть ошибки.
private var latitude: Double = DEFAULT_LATITUDE
private var longitude: Double = DEFAULT_LONGITUDE
private val radiusValues: Array<Int> = arrayOf(5, 10, 25, 50, 100, 200, 0)
private var locationManager: LocationManager? = null
private var locationListener: LocationListener? = null
override fun onCreateView(...) {
clickListener = View.OnClickListener {
when (it.id) {
R.id.center_location -> centerLocation()
R.id.continue_button -> showParametersFragment(regionId, cityId, latitude, ...)
}
private fun centerLocation() {
moveMapToLocation(latitude, longitude)
drawCircle(latitude, longitude)
if (locationManager?.isProviderEnabled(LocationManager.GPS_PROVIDER) == true ||
locationManager?.isProviderEnabled(LocationManager.NETWORK_PROVIDER) == true) {
initLocationListener()
} else {
showLocationSettingsDialog()
}
}
private fun drawCircle(latitude: Double, longitude: Double) {
if (radiusValues[currentRadiusIndex] == 0) {
removeCircle()
moveMapToLocation(latitude, longitude)
} else {
addCircle(latitude, longitude)
}
}
private fun initLocationListener() {
locationListener = object : LocationListener {
override fun onLocationChanged(location: Location) {
removeLocationUpdates()
locationListener = null
showUserLocation(location)
}
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
}
@SuppressLint("MissingPermission")
override fun onProviderEnabled(provider: String) {
if (isResumed) {
if (isLocationPermissionGranted()) {
locationManager?.getLastKnownLocation(provider)?.let {
showUserLocation(it)
}
}
} else {
locationProvider = provider
}
}
override fun onProviderDisabled(provider: String) {
}
}
locationManager =
context?.getSystemService(Context.LOCATION_SERVICE) as? LocationManager
setLocationUpdates()
}