Andorid Studio lass 'FlutterLocationService' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult
Solution 1
This has been fixed in the new version. Update the dependency in the pubspec.yml file to
location: ^4.4.0
Solution 2
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 3
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
Emirhan Selim Uzun
Hello Folks. I am Emirhan. I am a Computer Engineering Student at the University. I am interested in Flutter recently and I am improving myself day by day.
Updated on January 04, 2023Comments
-
Emirhan Selim Uzun over 1 year
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
-
Emirhan Selim Uzun almost 2 yearsYes, do that instead. With flutter 3.0.0 and location: ^4.4.0 package update problem fixed.