Out of nowhere, the build is crashing with a strange error related to the location component , the error is in the "src..\location\FlutterLocationService.kt:"
Here is the error:
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\location-4.3.0\android\src\main\java\com\lyokone\location\FlutterLocationService.kt: (124, 1): Class 'FlutterLocationService' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
Solution 1: Emirhan Selim Uzun
Well, I solved the problem just making 3 differences. First you will put "override" before the "fun" keyword. Then delete the question marks in front of "Array" this and "grantResults: IntArray" this.
It should be "Array?" , "grantResults: IntArray?" like this at the beginning just delete the question marks.
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && permissions!!.size == 2 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION && permissions[1] == Manifest.permission.ACCESS_BACKGROUND_LOCATION) {
if (grantResults!![0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
// Permissions granted, background mode can be enabled
enableBackgroundMode()
result?.success(1)
result = null
} else {
if (!shouldShowRequestBackgroundPermissionRationale()) {
result?.error("PERMISSION_DENIED_NEVER_ASK",
"Background location permission denied forever - please open app settings", null)
} else {
result?.error("PERMISSION_DENIED", "Background location permission denied", null)
}
result = null
}
}
return false
}
Solution 2: Czar
Update your location package to this for the main time
location:
git:
url: https://github.com/Yczar/flutterlocation.git
path: packages/location
you can also comment on the issue here
Solution 3: Ушаков Владимир
This has been fixed in the new version. Update the dependency in the pubspec.yml file to
location: ^4.4.0
Solution 4: Tanvir Ahmed
Goto External libraries -> Flutter Plugins -> location-x.x.x(package version) -> android -> src.main -> java.com.xxx.location -> FlutterLocationService.kt
Remove '?' from override fun onRequestPermissionResult parameters.