MissingPluginException(No implementation found in flutter using geolocator
Asked Answered
W

6

6

i am using geolocator in flutter project to get current location but this error come on it. i added all dependencies in both ios and android files still get this error i dont know why flutter channel stable, 2.12,

here is my code:

Position position = await Geolocato.getCurrentPosition( desiredAccuracy: LocationAccuracy.high);

here is my error coming which i tested android 10, 8 also, but answer same

Unhandled Exception: MissingPluginException(No implementation found for method getCurrentPosition on channel flutter.baseflow.com/geolocator)

i am using geolocator plugin here is plugin link :https://pub.dev/packages/geolocator

Woodenhead answered 4/6, 2021 at 9:24 Comment(6)
Sometimes its just because of old plugin cache. Try flutter clean and rebuild you app. Hopefully it will work fineCenobite
tried a lot but nothin works, app close then again run as same android studio did, but nothing changedWoodenhead
I used same plugin in one of my apps and it was working fine. Try the code here might help you github.com/m-hamzashakeel/Here-I-Am-Alert-AppCenobite
@Cenobite you add this plugin but not use anywhere i see no location permission anything else.Woodenhead
the locations will be on button press and same goes for permission. The file will be homeScreen or something like thatCenobite
This solution worked for me: enter link description hereDemented
G
4

Running flutter clean and flutter pub get fixed the issue for me. I uninstalled the application, cleared the cache of my device and rebuilt the app. This time there was a popup asking to give location permission to the app.

I gave the access and got the current position of the device (latitude and longitude).

Also make sure you upgrade flutter to 3.0.0 by running flutter upgrade

Glassware answered 20/5, 2022 at 18:57 Comment(0)
B
3

Maybe someone will need my solution. This happens because GeolocatorPlatform.instance is not initialized. Call _registerPlatformInstance() where you need.

import 'package:geolocator_android/geolocator_android.dart';
import 'package:geolocator_apple/geolocator_apple.dart';

void _registerPlatformInstance() {
    if (Platform.isAndroid) {
      GeolocatorAndroid.registerWith();
    } else if (Platform.isIOS) {
      GeolocatorApple.registerWith();
    }
}
Backbencher answered 23/5, 2022 at 9:22 Comment(0)
D
3

Stop running the app completely and restart the app. make sure that the app is killed before restart click stop button, refer below,

enter image description here

Demented answered 13/12, 2022 at 7:33 Comment(1)
Thats correct and probably the simplest way to solve this problemSandeesandeep
B
2

If you just installed the package (geolocator), just restart the app or even better the phone.

Bookbinder answered 24/7, 2022 at 14:17 Comment(1)
restarting helped. thanks!Sandeesandeep
P
0

Upgrade your flutter Run on terminal flutter upgrade or flutter upgrade —-force Then =>flutter pub outdated Then =>flutter pub upgrade After that =>flutter pub upgrade —-major-versions

Finally go to

yourProjectName/android/app/build.gradle

Change:

android {
   compileSdkVersion ##
…
…
}

To:

android {
   compileSdkVersion 33
…
…
}
Pent answered 11/8, 2022 at 23:19 Comment(0)
R
0

Rebuilding the project with newest version of Kotlin solved this issue for me.

Go to android > settings.gradel

and edit this line

id "org.jetbrains.kotlin.android" version "2.0.20" apply false

with the newest version of Kotlin available at https://kotlinlang.org/docs/releases.html#release-details.

After that, kill your app and rebuild it.

Ritualize answered 22/8, 2024 at 19:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.