Search code examples
androiddartflutterlocation-servicesgoogle-location-services

How to get current location on flutter sdk 1.2.1


How can i get current location on android device using flutter. I have tried both Location and GeoLocator plugins the GeoLocator 3.0.0 shows this error on debuging:

Launching lib\main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:preDebugBuild'.

    Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution

Location 2.0.0 also throws an error on debugging. There is another plugin available named geoLocation but that is not compatible with dart 2.0. In such a situation how can i get location (longitude and latitude)[once]? Any help would be highly appreciated.


Solution

  • The geoLocator plugin that I installed was using Android x jetpack libraries while my project was using support libraries so this conflict was causing the problem and when I updated my project to use Android x libraries the problem was resolved.