Giter VIP home page Giter VIP logo

geolocation's Introduction

geolocation

pub package

Flutter geolocation plugin for Android API 16+ and iOS 9+.

Features:

  • Manual and automatic location permission management
  • Current one-shot location
  • Continuous location updates with foreground and background options

The plugin is under active development and the following features are planned soon:

  • Geocode
  • Geofences
  • Place suggestions
  • Activity recognition
  • Exposition of iOS/Android specific APIs (like significant location updates on iOS)
Android iOS

Installation

Follow the instructions: https://pub.dev/packages/geolocation#-installing-tab-

iOS

Objective-C compatibility

For Flutter projects created with the Objective-C template, you might need to add use_frameworks! at the top of ios/Podfile. More details can be found in the following issue: flutter/flutter#16049 (comment)

Android

AndroidX

Geolocation is dependent on AndroidX. Make sure to include the following settings to 'android/gradle.properties':

android.useAndroidX=true
android.enableJetifier=true
R8/Proguard code obfuscation

If you have enabled code obfuscation with R8 or proguard, you need to add the following rules.

android/app/build.gradle:

buildTypes {
  release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

android/app/proguard-rules.pro:

# Geolocation - start

-keep class app.loup.geolocation.** { *; }

    # Moshi - start
    # https://github.com/square/moshi/blob/master/moshi/src/main/resources/META-INF/proguard/moshi.pro

    # JSR 305 annotations are for embedding nullability information.
    -dontwarn javax.annotation.**

    -keepclasseswithmembers class * {
        @com.squareup.moshi.* <methods>;
    }

    -keep @com.squareup.moshi.JsonQualifier interface *

    # Enum field names are used by the integrated EnumJsonAdapter.
    # values() is synthesized by the Kotlin compiler and is used by EnumJsonAdapter indirectly
    # Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi.
    -keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum {
        <fields>;
        **[] values();
    }

    # Moshi - end

# Geolocation - end

Permission

Android and iOS require to declare the location permission in a configuration file.

For iOS

There are two kinds of location permission available in iOS: "when in use" and "always".

If you don't know what permission to choose for your usage, see: https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services

You need to declare the description for the desired permission in ios/Runner/Info.plist:

<dict>
  <!-- for iOS 11 + -->
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>

  <!-- additionally for iOS 9/10, if you need always permission -->
  <key>NSLocationAlwaysUsageDescription</key>
  <string>Reason why app needs location</string>
  ...
</dict>

For Android

There are two kinds of location permission in Android: "coarse" and "fine". Coarse location will allow to get approximate location based on sensors like the Wifi, while fine location returns the most accurate location using GPS (in addition to coarse).

You need to declare one of the two permissions in android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <!-- or -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Note that ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION.

API

For more complete documentation on all usage, check the API documentation:
https://pub.dartlang.org/documentation/geolocation/latest/geolocation/geolocation-library.html

You can also check the example project that showcase a comprehensive usage of Geolocation plugin.

Check if location service is operational

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/isLocationOperational.html

final GeolocationResult result = await Geolocation.isLocationOperational();
if(result.isSuccessful) {
  // location service is enabled, and location permission is granted
} else {
  // location service is not enabled, restricted, or location permission is denied
}

Request location permission

On Android (api 23+) and iOS, apps need to request location permission at runtime.

Note: You are not required to request permission manually. Geolocation plugin will request permission automatically if it's needed, when you make a location request.

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/requestLocationPermission.html

final GeolocationResult result = await Geolocation.requestLocationPermission(
  const LocationPermission(
    android: LocationPermissionAndroid.fine,
    ios: LocationPermissionIOS.always,
  ),
  openSettingsIfDenied: true,
);

if(result.isSuccessful) {
  // location permission is granted (or was already granted before making the request)
} else {
  // location permission is not granted
  // user might have denied, but it's also possible that location service is not enabled, restricted, and user never saw the permission request dialog. Check the result.error.type for details.
}

Get the current one-shot location

Geolocation offers three methods:

// get last known location, which is a future rather than a stream (best for android)
LocationResult result = await Geolocation.lastKnownLocation();

// force a single location update (best for ios)
StreamSubscription<LocationResult> subscription = Geolocation.currentLocation(accuracy: LocationAccuracy.best).listen((result) {
  // todo with result
});

// best option for most cases
StreamSubscription<LocationResult> subscription = Geolocation.currentLocation(accuracy: LocationAccuracy.best).listen((result) {
  if(result.isSuccessful) {
    Double latitude = result.location.latitude;
    // todo with result
  }
});

Continuous location updates

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/Geolocation/locationUpdates.html

StreamSubscription<LocationResult> subscription = Geolocation.locationUpdates(
    accuracy: LocationAccuracy.best,
    displacementFilter: 10.0, // in meters
    inBackground: true, // by default, location updates will pause when app is inactive (in background). Set to `true` to continue updates in background.
  )
  .listen((result) {
    if(result.isSuccessful) {
      // todo with result
    }
  });


// cancelling subscription will also stop the ongoing location request
subscription.cancel();

Handle location result

Location request return either a LocationResult future or a stream of LocationResult.

API documentation: https://pub.dartlang.org/documentation/geolocation/latest/geolocation/LocationResult-class.html

LocationResult result = await Geolocation.lastKnownLocation();

if (result.isSuccessful) {
  // location request successful, location is guaranteed to not be null
  double lat = result.location.latitude;
  double lng = result.location.longitude;
} else {
  switch (result.error.type) {
    case GeolocationResultErrorType.runtime:
      // runtime error, check result.error.message
      break;
    case GeolocationResultErrorType.locationNotFound:
      // location request did not return any result
      break;
    case GeolocationResultErrorType.serviceDisabled:
      // location services disabled on device
      // might be that GPS is turned off, or parental control (android)
      break;
    case GeolocationResultErrorType.permissionNotGranted:
      // location has not been requested yet
      // app must request permission in order to access the location
      break;
    case GeolocationResultErrorType.permissionDenied:
      // user denied the location permission for the app
      // rejection is final on iOS, and can be on Android if user checks `don't ask again`
      // user will need to manually allow the app from the settings, see requestLocationPermission(openSettingsIfDenied: true)
      break;
    case GeolocationResultErrorType.playServicesUnavailable:
      // android only
      // result.error.additionalInfo contains more details on the play services error
      switch(result.error.additionalInfo as GeolocationAndroidPlayServices) {
        // do something, like showing a dialog inviting the user to install/update play services
        case GeolocationAndroidPlayServices.missing:
        case GeolocationAndroidPlayServices.updating:
        case GeolocationAndroidPlayServices.versionUpdateRequired:
        case GeolocationAndroidPlayServices.disabled:
        case GeolocationAndroidPlayServices.invalid:
      }
    break;
  }
}

Authors

Geolocation plugin is developed by Loup, a mobile development studio based in Montreal and Paris.
You can contact us at [email protected]

Contributers

  • lukaspili
  • mit-mit
  • shehabic-work
  • Abgaryan
  • shehabic
  • alfanhui

License

Apache License 2.0

geolocation's People

Contributors

alfanhui avatar bilalasd avatar caioflandau avatar lukaspili avatar mit-mit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geolocation's Issues

Get the location updates after each 1 minute?

Hi, I want to create an app like Uber, and I want to get the location updates of the user after each 1 minute even if the app is running in the background is there a way to do this using your library?

I want the solution to work for both Android and Ios.

kindly let me know Thanks.

Podfile error on iOS device.

Thanks for the plugin.
I am trying to use it in my app and when I use it and run my app on an iPhone 7 iOS 11.2.5 it throws the following error while running the pod install:
Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile.

No static method '_fromJson' declared in class 'LocationResult'

I was testing this plugin. I ran this code

import 'package:geolocation/geolocation.dart';

find() async {
    LocationResult result = await Geolocation.currentLocation(LocationAccuracy.best);
}

I got this error

[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
NoSuchMethodError: No static method '_fromJson' declared in class 'LocationResult'.
Receiver: LocationResult
Tried calling: _fromJson(_LinkedHashMap len:2)
#0      NoSuchMethodError._throwNew (dart:core-patch/dart:core/errors_patch.dart:192)
#1      _Codec.decodeLocation (package:geolocation/channel/codec.dart:8:22)
#2      _Api.currentLocation (package:geolocation/channel/api.dart:20:19)
<asynchronous suspension>
#3      Geolocation.currentLocation (package:geolocation/geolocation.dart:52:12)
<asynchronous suspension>
#4      UserLocation.find (/Users/gorjan/Projects/aero/lib/models/UserLocation.dart:18:47)
<asynchronous suspension>
#5      HomeState.initState (/Users/gorjan/Projects/aero/lib/pages/home.dart:26:26)
#6      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
#7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
#8      Element.inflateWidget (package:flutter/src/widgets/framework

Testing on iPhone X iOS 11.3

Pubspec

 geolocation: "0.1.1"

Raise com.google.android.gms version

I had to force a higher version for com.google.android.gms. I am currently using 15.0.1, which appears to work. This version is requested by the google maps plugin by google.

To work around this I added the following the build.grade:

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.google.android.gms') {
                details.useVersion "15.0.1"
            }
        }
    }
}

This works, but a proper fix would be to raise the upper version bound.

Could not build for Android

Build fail with the following error:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (25.2.0) and runtime (26.1.0) classpath. You should manually set the same version via DependencyResolution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
Finished with error: Gradle build failed: 1

Flutter

[✓] Flutter (Channel master, v0.5.8-pre.228, on Linux, locale en_US.UTF-8)
    • Flutter version 0.5.8-pre.228 at /home/k/flutter
    • Framework revision 9e832121d0 (2 hours ago), 2018-08-02 17:07:36 -0700
    • Engine revision 4893b0760d
    • Dart version 2.0.0-dev.69.5.flutter-8bad5c7b29

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /home/k/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /home/k/opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.1)
    • Android Studio at /home/k/opt/android-studio
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2)
    • IntelliJ at /home/k/opt/idea-IU-181.4668.68
    • Flutter plugin version 26.0.3
    • Dart plugin version 182.3569.4

[✓] VS Code (version 1.25.1)
    • VS Code at /usr/share/code
    • Flutter extension version 2.12.2

[✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)

• No issues found!

Failed to capture snapshot of input files for task ':geolocation:compileDebugAidl' property 'importDirs' during up-to-date check

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
}
Crashing when using google-services.
What went wrong:
Failed to capture snapshot of input files for task ':geolocation:compileDebugAidl' property 'importDirs' during up-to-date check.

The library com.google.android.gms:play-services-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0. ...

//////////////////////////////////////////////////

./gradlew :app:dependencies.

releaseCompileClasspath - Resolved configuration for compilation for variant: release
+--- project :geolocation
| *--- com.google.android.gms:play-services-location:[11.4.0,12.0[ -> 15.0.1**
| +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 15.0.1
| | +--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1
| | | --- com.android.support:support-v4:26.1.0
| | | +--- com.android.support:support-compat:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | --- android.arch.lifecycle:runtime:1.0.0
| | | | +--- android.arch.lifecycle:common:1.0.0
| | | | | --- com.android.support:support-annotations:26.1.0
| | | | +--- android.arch.core:common:1.0.0
| | | | | --- com.android.support:support-annotations:26.1.0
| | | | --- com.android.support:support-annotations:26.1.0
| | | +--- com.android.support:support-media-compat:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | --- com.android.support:support-compat:26.1.0 (
)
| | | +--- com.android.support:support-core-utils:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | --- com.android.support:support-compat:26.1.0 ()
| | | +--- com.android.support:support-core-ui:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0
| | | | --- com.android.support:support-compat:26.1.0 (
)
| | | --- com.android.support:support-fragment:26.1.0
| | | +--- com.android.support:support-compat:26.1.0 ()
| | | +--- com.android.support:support-core-ui:26.1.0 (
)
| | | --- com.android.support:support-core-utils:26.1.0 ()
| | --- com.google.android.gms:play-services-tasks:[15.0.1] -> 15.0.1
| | --- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (
)
| +--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 ()
| +--- com.google.android.gms:play-services-places-placereport:[15.0.1,16.0.0) -> 15.0.1
| | --- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (
)
| --- com.google.android.gms:play-services-tasks:[15.0.1,16.0.0) -> 15.0.1 (*)

//////////////////////////////////////////////////////

  • Exception is:
    org.gradle.api.UncheckedIOException: Failed to capture snapshot of input files for task ':geolocation:compileDebugAidl' property 'importDirs' during up-to-date check.
    at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.snapshotTaskFiles(CacheBackedTaskHistoryRepository.java:333)
    at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.createExecution(CacheBackedTaskHistoryRepository.java:154)
    at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.access$100(CacheBackedTaskHistoryRepository.java:61)
    at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository$1.getCurrentExecution(CacheBackedTaskHistoryRepository.java:114)
    at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:201)
    at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:86)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:59)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:128)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:46)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:314)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:204)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:134)
    at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
    at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
    at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:69)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:30)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    Caused by: org.gradle.api.GradleException: The library com.google.android.gms:play-services-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
    at com.google.gms.googleservices.GoogleServicesPlugin$1$_afterResolve_closure1.doCall(GoogleServicesPlugin.groovy:328)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
    at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
    at org.gradle.util.ConfigureUtil$1.execute(ConfigureUtil.java:123)
    at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.eachElement(DefaultResolutionResult.java:70)
    at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.eachElement(DefaultResolutionResult.java:74)
    at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.eachElement(DefaultResolutionResult.java:74)
    at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.allComponents(DefaultResolutionResult.java:86)
    at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.allComponents(DefaultResolutionResult.java:90)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.allComponents(ErrorHandlingConfigurationResolver.java:227)
    at org.gradle.api.artifacts.result.ResolutionResult$allComponents.call(Unknown Source)
    at com.google.gms.googleservices.GoogleServicesPlugin$1.afterResolve(GoogleServicesPlugin.groovy:311)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:371)
    at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:353)
    at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
    at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:341)
    at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:328)
    at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
    at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
    at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
    at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
    at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy30.afterResolve(Unknown Source)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$4.run(DefaultConfiguration.java:491)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:474)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:459)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$1700(DefaultConfiguration.java:116)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:901)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:889)
    at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:68)
    at org.gradle.api.internal.changedetection.state.AbstractFileCollectionSnapshotter$FileCollectionVisitorImpl.visitCollection(AbstractFileCollectionSnapshotter.java:70)
    at org.gradle.api.internal.file.AbstractFileCollection.visitRootElements(AbstractFileCollection.java:234)
    at org.gradle.api.internal.file.CompositeFileCollection.visitRootElements(CompositeFileCollection.java:185)
    at org.gradle.api.internal.changedetection.state.AbstractFileCollectionSnapshotter.snapshot(AbstractFileCollectionSnapshotter.java:53)
    at org.gradle.api.internal.changedetection.state.DefaultGenericFileCollectionSnapshotter.snapshot(DefaultGenericFileCollectionSnapshotter.java:38)
    at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.snapshotTaskFiles(CacheBackedTaskHistoryRepository.java:331)
    ... 106 more

Any thoughts?

Dart SDK version (2.1.0) is not supported by geolocation

From @markflarup on September 5, 2018 8:35

URL: https://pub.dartlang.org/packages/geolocation#-installing-tab-

I want to support geo location in an app, but after adding geolocation: ^0.2.1 as a dependency the following error message is returned:

The current Dart SDK version is 2.1.0-dev.0.0.flutter-be6309690f.

Because [APP] depends on geolocation >=0.1.1 which requires SDK version <2.0.0, version solving failed.
pub get failed (1)

Do you have a estimate for when it will be supported?

Copied from original issue: dart-lang/pub-dev#1580

attempting to use `await for` causes issues.

I am building an application for a tutorial that I am writing and I am finding that when I use any of the methods aside from lastKnownLocation(), I can't get access to the one shot data in the streams using the await for construct.

From what I can tell based on the documentation, the currentLocation() method should just be a stream with a single value inside of it and yet when I write something like the block below, the application just sits indefinitely waiting for the stream to complete (I tried adding an onDone and onError to see if there were any problems in that regard).

getLocation() async {
  LocationResult location;
    Stream<LocationResult> results = Geolocation.currentLocation(
        accuracy: LocationAccuracy.best, inBackground: false);

    await for (LocationResult data in results) {
      location = data;
    }

    return location;
}

I did a bit of debugging and it seems that the data and location variables stay null the entire time the function is running. Am I just missing something here?

Also, I have a question regarding the lastKnownLocation() function. Based on the android documentation, it should change with some degree of frequency and yet, even if I turn off the GPS and rebuild the application, the last known location will not change unless I power down the emulator and reboot it. Is this just how it works or is it something else?

Android Permission Best Practices

I have been evaluating the popular location permission libraries with flutter to see how it matches with the best practices. Below is what I found with your library. Let me know if there are ways to get this to work that I missed.

Android Best Practices
https://developer.android.com/distribute/best-practices/develop/runtime-permissions
https://developer.android.com/training/permissions/requesting
So below is my understanding of the best practices.

if (Location Services Disabled)
    A) Show Location Services Dialog 
else if (Location Services Enabled)
    If(Permission Denied Forever)
        B) Show Dialog that says permission denied forever and will show Settings
            C) Redirect to app settings
    else if(Denied Once && Permission Rational provided)
        D) Show Permission Rational
                  Show Permission Dialog
    else
        E) Show Permission Dialog

So the library does not support
B. So if permissions are denied forever I would think it would be best to show some sort of dialog before redirecting the user to the settings page. The library does redirect the user to the settings page but let's say I want to show a dialog. I could set openSettingsIfDenied to false but I have no way to discern between denied forever and just denied.

D. The library has no means to show the permission dialog after it was denied once. Which is when the permission rational would be shown. Also android returns when you should show this which the API should expose.
E. I failed this one because if someone denys once they will never see the dialog again.

Summary
I think these are the changes required for users of the library to implement permissions.

  1. Keep showing the permission dialog if not denied forever
  2. Be able to get back that google says to show permission rational. Also would be good if there was a way to pass that rational while requesting location and it shows that as a dialog. Could use this same rational for deny forever dialog.
  3. Get back from response if denied vs denied forever

Let me know if you need any clarification.

Error, need to add one of ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION to AndroidManifest.xml

I'm getting this error:

"Missing location permission in AndroidManifest.xml. You need to add one of ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION. See readme for details."

However, I already added ACCESS_COARSE_LOCATION:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ranky">

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>

    <!-- The location permission is required for showing close contests to
         the user.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

...

Android App crashes

E/AndroidRuntime( 9484): java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode E/AndroidRuntime( 9484): at android.support.v4.app.BaseFragmentActivityApi14.checkForValidRequestCode(BaseFragmentActivityApi14.java:79) E/AndroidRuntime( 9484): at android.support.v4.app.FragmentActivity.validateRequestPermissionsRequestCode(FragmentActivity.java:765) E/AndroidRuntime( 9484): at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:505) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.requestPermission(LocationClient.kt:288) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.validateServiceStatus(LocationClient.kt:245) E/AndroidRuntime( 9484): at io.intheloup.geolocation.location.LocationClient.requestLocationPermission(LocationClient.kt:71) E/AndroidRuntime( 9484): at io.intheloup.geolocation.LocationChannel$requestLocationPermission$1.doResume(LocationChannel.kt:31) E/AndroidRuntime( 9484): at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54) E/AndroidRuntime( 9484): at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161) E/AndroidRuntime( 9484): at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25) E/AndroidRuntime( 9484): at android.os.Handler.handleCallback(Handler.java:739) E/AndroidRuntime( 9484): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 9484): at android.os.Looper.loop(Looper.java:158) E/AndroidRuntime( 9484): at android.app.ActivityThread.main(ActivityThread.java:7229) E/AndroidRuntime( 9484): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 9484): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) E/AndroidRuntime( 9484): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

fatal error: 'geolocation/geolocation-Swift.h' file not found

Xcode's output:

/Users/delphix/Documents/Sdk/flutter/.pub-cache/git/geolocation-5f7e2ec8a00fa0c020791c5b0c1844b2bd320c05/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found
#import <geolocation/geolocation-Swift.h>

Exception error when requesting current or single update in example app?

I ran the example application provided by the repo and while the first and all subsequent 'Last Known' location works - clicking 'Current' or 'Single Update' only shows 'In progress...'

The error log is as follows:

I/flutter ( 9240): ══╡ EXCEPTION CAUGHT BY GEOLOCATION ╞═══════════════════════════════════════════════════════════════
I/flutter ( 9240): The following PlatformException was thrown while invoking
I/flutter ( 9240): geolocation/location/addLocationUpdatesRequest:
I/flutter ( 9240): PlatformException(error, Expected BEGIN_OBJECT but was STRING at path $.options, null)
I/flutter ( 9240):
I/flutter ( 9240): When the exception was thrown, this was the stack:
I/flutter ( 9240): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:547:7)
I/flutter ( 9240): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
I/flutter ( 9240): <asynchronous suspension>
I/flutter ( 9240): #2      _invokeChannelMethod (file:///C:/Users/addis/Downloads/geolocation-master/geolocation-master/lib/channel/helper.dart:12:26)
I/flutter ( 9240): <asynchronous suspension>
I/flutter ( 9240): #3      _LocationChannel.locationUpdates.<anonymous closure> (file:///C:/Users/addis/Downloads/geolocation-master/geolocation-master/lib/channel/location_channel.dart:101:9)
I/flutter ( 9240): #8      _TabLocationState._listenToLocation (file:///C:/Users/addis/Downloads/geolocation-master/geolocation-master/example/lib/tab_location.dart:49:33)
I/flutter ( 9240): #9      _TabLocationState._onCurrentPressed (file:///C:/Users/addis/Downloads/geolocation-master/geolocation-master/example/lib/tab_location.dart:38:5)
I/flutter ( 9240): #10     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter ( 9240): #11     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
I/flutter ( 9240): #12     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:123:7)
I/flutter ( 9240): #13     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
I/flutter ( 9240): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
I/flutter ( 9240): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
I/flutter ( 9240): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
I/flutter ( 9240): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
I/flutter ( 9240): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
I/flutter ( 9240): #19     _invoke1 (dart:ui/hooks.dart:134:13)
I/flutter ( 9240): #20     _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
I/flutter ( 9240): (elided 4 frames from package dart:async)
I/flutter ( 9240): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 9240): location result: null

The app was run on the default AVD Nexus 5X device on Android 8.1.

Support for mock locations

Is there support for detecting when user tries to mock locations in this plugin? I could not find anything related to it in the reference. Is there any plan to add it?

Running in background does not work

Hello,

I've tried your package expecting to run it in background, but unfortunately it does not work. The example app runs fine while active (printing the logs), and when the Track option is activated and the app lost focus, the log stops to print.

p.s.: i've changed the parameter inBackground from false to true to suposely activate the background service, but no luck with it.

App Crashing after integrating geolocation

I'm experiencing and issue where my app can no longer launch after integrating the geolocation plugin.

I'm seeing the following error:

04-20 10:38:07.162 28097-28097/greensensor.com.greensensor E/AndroidRuntime: FATAL EXCEPTION: main
Process: greensensor.com.greensensor, PID: 28097
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
at com.google.android.gms.location.LocationServices.(Unknown Source:0)
at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:0)
at io.intheloup.geolocation.location.LocationClient.(LocationClient.kt:40)
at io.intheloup.geolocation.GeolocationPlugin.(GeolocationPlugin.kt:14)
at io.intheloup.geolocation.GeolocationPlugin$Companion.registerWith(GeolocationPlugin.kt:57)
at io.intheloup.geolocation.GeolocationPlugin.registerWith(Unknown Source:2)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:29)
at greensensor.com.greensensor.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Api$zzf" on path: DexPathList[[zip file "/data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/base.apk"],nativeLibraryDirectories=[/data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/lib/arm64, /system/fake-libs64, /data/app/greensensor.com.greensensor-GIph4HLdX8jz_m5c7vM3jQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
...
...

considering the Dex comment in that log, i'm suspecting a Play Services versioning issue, but i'm not sure how to fix that

geolocation not building in iOS

=== BUILD TARGET uni_links OF PROJECT Pods WITH CONFIGURATION Release ===
/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.1.6/ios/Classes/FlutterWebviewPlugin.m:59:22: warning: incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'id _Nullable' [-Wint-conversion]
_enableAppScheme = call.arguments[@"enableAppScheme"];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.1.6/ios/Classes/FlutterWebviewPlugin.m:188:78: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]
id data = [FlutterError errorWithCode:[NSString stringWithFormat:@"%ld", error.code]
~~~ ^~~~~~~~~~
%ld (long)
2 warnings generated.
/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found
#import <geolocation/geolocation-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found
#import <geolocation/geolocation-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:31: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewController:(SFSafariViewController *)controller
^
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:1: note: annotate 'safariViewController:didCompleteInitialLoad:' with an availability attribute to silence this warning
- (void)safariViewController:(SFSafariViewController *)controller
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:40: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:1: note: annotate 'safariViewControllerDidFinish:' with an availability attribute to silence this warning
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
API_AVAILABLE(ios(9.0))
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:29:31: warning: comparison between pointer and integer ('NSInteger' (aka 'int') and 'void *')
if (_previousStatusBarStyle != nil) {
~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:111:45: warning: comparison between pointer and integer ('NSInteger' (aka 'int') and 'void ')
if (self->_previousStatusBarStyle != nil) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: warning: 'openURL:options:completionHandler:' is only available on iOS 10.0 or newer [-Wunguarded-availability]
[application openURL:url
^~~~~~~~~~~
In module 'UIKit' imported from /NevesSoftware/ns_giftcard2/loyality/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:1: note: 'openURL:options:completionHandler:' has been explicitly marked partial here
- (void)openURL:(NSURL
)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: note: enclose 'openURL:options:completionHandler:' in an@available check to silence this warning
[application openURL:url
^~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
7 warnings generated.
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:31: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewController:(SFSafariViewController *)controller
^
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:27:1: note: annotate 'safariViewController:didCompleteInitialLoad:' with an availability attribute to silence this warning
- (void)safariViewController:(SFSafariViewController *)controller
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:40: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:43:1: note: annotate 'safariViewControllerDidFinish:' with an availability attribute to silence this warning
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
^
API_AVAILABLE(ios(9.0))
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:29:31: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void *')
if (_previousStatusBarStyle != nil) {
~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:111:45: warning: comparison between pointer and integer ('NSInteger' (aka 'long') and 'void ')
if (self->_previousStatusBarStyle != nil) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: warning: 'openURL:options:completionHandler:' is only available on iOS 10.0 or newer [-Wunguarded-availability]
[application openURL:url
^~~~~~~~~~~
In module 'UIKit' imported from /NevesSoftware/ns_giftcard2/loyality/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:1: note: 'openURL:options:completionHandler:' has been explicitly marked partial here
- (void)openURL:(NSURL
)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:108:18: note: enclose 'openURL:options:completionHandler:' in an@available check to silence this warning
[application openURL:url
^~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:3: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: warning: 'SFSafariViewController' is only available on iOS 9.0 or newer [-Wunguarded-availability]
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
In module 'SafariServices' imported from /.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:5:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h:27:12: note: 'SFSafariViewController' has been explicitly marked partial here
@interface SFSafariViewController : UIViewController
^
/.pub-cache/hosted/pub.dartlang.org/url_launcher-3.0.3/ios/Classes/UrlLauncherPlugin.m:140:38: note: enclose 'SFSafariViewController' in an @available check to silence this warning
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
^~~~~~~~~~~~~~~~~~~~~~
7 warnings generated.
Encountered error while building for device.
philipneves@Philips-MacBook-Pro:~/NevesSoftware/ns_giftcard2/loyality$ flutter run
Launching lib/main.dart on Philip Neves’s iPod in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: HDUGN2FSU6
Running pod install... 2.0s
Starting Xcode build...
Xcode build done. 7.9s
Failed to build iOS app
Error output from Xcode build:

** BUILD FAILED **

Xcode's output:

/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/ios/Classes/GeolocationPlugin.m:7:9: fatal error: 'geolocation/geolocation-Swift.h' file not found
#import <geolocation/geolocation-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Could not build the precompiled application for the device.

Value for SWIFT_VERSION cannot be empty. (in target 'geolocation')

Failed to build iOS app
Error output from Xcode build:

2018-08-09 09:55:51.479 xcodebuild[43891:331279] warning: file type '::com.apple.instruments.instrdst' is based on missing file type 'default::com.apple.package'
** BUILD FAILED **
Xcode's output:

error: Value for SWIFT_VERSION cannot be empty. (in target 'geolocation')

iOS Permission Best Practices

I have been evaluating the popular location permission libraries with flutter to see how it matches with the best practices. Below is what I found with your library. Let me know if there are ways to get this to work that I missed.

iOS Best Practices
So below is my understanding of the best practices. You can see Google Maps and other apps doing the below

If (Location Services Disabled)
    A) Show Location Services Dialog
        Redirect to Location Services Settings
else if(Location permission denied)
    B) Show Dialog saying to enable permission
        Redirect to App Settings
else
    C) Show Permission dialog

So the library does not support
A. The library does not show the dialog that gives the user the option to enable location services.

B. The library ignores the permission request. It would be good if you had an option to show a dialog and redirect to the app settings.

Summary
I think these are the changes required for users of the library to implement permissions.

  1. Show dialog to enable location services when location services are disabled.
  2. Automatically show a dialog that we can pass the title and message when requesting location when permission denied. Have an option to not do that automatically.

Let me know if you need any clarification.

iOS build fails

running flutter build ios --release :

=== BUILD TARGET firebase_messaging OF PROJECT Pods WITH CONFIGURATION Release ===
/Users/****/development/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-0.0.1/ios/Classes/GeolocatorPlugin.m:2:9: fatal error: 'geolocator/geolocator-Swift.h' file not found
#import <geolocator/geolocator-Swift.h>

My doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.5.5, on Mac OS X 10.13.3 17D102, locale pt-PT)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✗] Android Studio (not installed)
[!] VS Code (version 1.14.2)
[!] Connected devices
! No devices available

Background service not working with Android O

Android O has changed the way things work in the background, and this service will not work on an Android O device in the background.

To reproduce, run the example project on a virtual Android O device, while subscribed to location updates, turn off the screen of the device. Updates stop (actually slow down to about once every 30 minutes) until the screen is turned back on.

NoSuchMethodError: The getter 'last' was called on null.

Plugin doesn't work, i use the forked plugin by shehabic https://github.com/shehabic/geolocation for Dart 2 compatibility

this is the error that return

[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
NoSuchMethodError: The getter 'last' was called on null.
Receiver: null
Tried calling: last
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 LocationResult.location (file:///Library/flutter/.pub-cache/git/geolocation-5f7e2ec8a00fa0c020791c5b0c1844b2bd320c05/lib/data/location_result.dart:27:38)
#2 LocationResult.dataToString (file:///Library/flutter/.pub-cache/git/geolocation-5f7e2ec8a00fa0c020791c5b0c1844b2bd320c05/lib/data/location_result.dart:31:12)
#3 _MyHomePageState.initGeolocation. (package:sequi/main.dart:77:25)
#4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#6 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#7 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
#8 _PendingEvents.schedule. (dart:async/stream_impl.dart<…>

my code is very simple,

// init background geolocation
void initGeolocation() async {
debugPrint('geo');
_geoSubscription = Geolocation.locationUpdates(
accuracy: LocationAccuracy.best,
displacementFilter: 10.0, // in meters
inBackground:
true, // by default, location updates will pause when app is inactive (in background). Set to true to continue updates in background.
).listen((result) {
debugPrint('result');
debugPrint(result.dataToString());
if (result.isSuccessful) {
// todo with result
_latitude = result.location.latitude;
_longitude = result.location.longitude;
debugPrint(result.dataToString());
}
});
}

Build failed with an exception

I can't able to include the plugin in my flutter app. Whenever I'm trying to include the plugin in my pubspec.yml file I'm getting following error & build is getting fail.

Running "flutter packages get" in bhramaan...
Launching lib/main.dart on Pixel 2 XL in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Finished with error: Gradle build failed: 1

My pubspec.yml file dependancises list is

dependencies:
  flutter:
    sdk: flutter
  google_sign_in: "^3.0.4"
  firebase_auth: "^0.5.11"
  shared_preferences: "^0.4.2"
  cloud_firestore: "^0.7.3"
  firebase_storage: "^0.3.7"
  image_picker: "^0.4.4"
  progress_hud: "^1.0.0"
  cached_network_image: "^0.4.1+1"
  intl: "^0.15.6"
  path: "^1.5.1"
  geolocation: "^0.2.1"

My app>build.gradle file content

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.bhramaan.bhramaan"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply plugin: 'com.google.gms.google-services'

My flutter doctor -v response

➜  bhramaan flutter doctor -v
[✓] Flutter (Channel master, v0.5.2-pre.78, on Mac OS X 10.13.5 17F77, locale en-IN)
    • Flutter version 0.5.2-pre.78 at /Users/sureshkumarmajhi/flutter
    • Framework revision 3b9b5acefc (2 days ago), 2018-06-07 10:07:52 -0700
    • Engine revision fca976d8c7
    • Dart version 2.0.0-dev.60.0.flutter-a5e41681e5

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/sureshkumarmajhi/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4, Build version 9F1027a
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 25.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[!] VS Code (version 1.21.1)
    • VS Code at /Users/sureshkumarmajhi/Applications/Visual Studio Code.app/Contents
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected devices (1 available)
    • Pixel 2 XL • 803KPSL1600646 • android-arm64 • Android 8.1.0 (API 27)

! Doctor found issues in 1 category.

Support setting 'interval' and 'fastestInterval' for continuous updates

Thank you for making this plugin available!

It would be nice if, when subscribing to locationUpdates(), if both interval and fastestInverval could be passed in and used, rather than the hard-coded values of 5000 and 2500 ms, respectively. This is for the android implementation, I'm not sure if the same applies to iOS.

This could look just like the displacementFilter parameter that is currently passed into that method.

enableLocationServices Is not working for ios

I get MissingPluginException when i call Geolocation.enableLocationServices()

flutter: location result: invoke geolocation/location->enableLocationServices []
flutter: ══╡ EXCEPTION CAUGHT BY GEOLOCATION ╞═══════════════════════════════════════════════════════════════
flutter: The following MissingPluginException was thrown while invoking
flutter: geolocation/location/enableLocationServices:
flutter: MissingPluginException(No implementation found for method enableLocationServices on channel
flutter: geolocation/location)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
flutter:
flutter: #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
flutter: #2 _invokeChannelMethod (package:geolocation/channel/helper.dart:12:26)
flutter: #3 _LocationChannel.enableLocationServices (package:geolocation/channel/location_channel.dart:60:28)
flutter: #4 Geolocation.enableLocationServices (package:geolocation/geolocation.dart:55:24)
flutter: #5 _MyAppState.enableLocationServices (package:geolocation_example/main.dart:80:17)
flutter: #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:14)
flutter: #7 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:862:36)
flutter: #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
flutter: #9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
flutter: #10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
flutter: #11 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
flutter: #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:470:9)
flutter: #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
flutter: #14 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:117:9)
flutter: #15 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
flutter: #16 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
flutter: #17 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
flutter: #18 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
flutter: #19 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
flutter: #20 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
flutter: #21 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
flutter: #22 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
flutter: #26 _invoke1 (dart:ui/hooks.dart:275:10)
flutter: #27 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)

Please create new version of "currentLocation" function as a Promise

For some reasons, can we make it like a Promise so we can use it with Synchronous coding with await/sync?
Now, this function returns a Stream, right? I hope I can get the value of currentLocation in initState function by using with "await".
Thanks for your time. Let me know if it's not clear for you. Thanks!

Building for release with minifyEnabled true not working

When I build for release with option minifyEnabled true in build-grable,
the plugin crash when I call Geolocation.requestLocationPermission with error:
FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(60)] Check failed: CheckException(env).

for information pubsec.yaml:
cupertino_icons: ^0.1.2
shared_preferences: ^0.4.1
intl: ^0.15.0
intl_translation: ^0.16.7
url_launcher: ^3.0.0
font_awesome_flutter: ^7.0.0
geolocation: ^0.2.1

Crash, java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api

As soon as i add the geolocation to my pubspec the app starts to crash whenever i try to use this plugin - java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api
I am using:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, v0.4.5-pre.69, on Microsoft Windows [Version 10.0.16299.371], locale pt-PT)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[√] VS Code, 32-bit edition (version 1.23.1)
[√] Connected devices (1 available)

• No issues found!

app's crashing

When i call the dependencies cloud_firestore and geolocation together my app crashes and i can't figure out why.
If i put only one of them it works fine.

Does it work if the app is closed ?

"Flutter plugin for location / geolocation / GPS. Supports iOS and Android. Multiple settings for speed, precision, battery optimization, continuous updates in background "

In background here means we can keep updates even the app is not in foreground (closed may be by the system or when click back).

"Missing location usage description values in Info.plist" even if it isn't the case.

So I changed my Info.plist file like explained in the README :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>I need you I need you I need you right now</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>tplusg</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>arm64</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
</dict>
</plist>

But it throws me this error saying it can't find the location usage description values in Info.plist :

[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
Geolocation error: Missing location usage description values in Info.plist. See readme for details.
#0      _JsonCodec.resultErrorFromJson (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:70:7)
#1      _JsonCodec.resultFromJson (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:47:33)
#2      _Codec.decodeResult (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/codec.dart:8:18)
#3      _LocationChannel.isLocationOperational (file:///Users/gaetan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/geolocation-0.2.1/lib/channel/location_channel.dart:37:19)
<asynchronous suspension>
#4      Geolocation.isLocationOperational (package:geolocation/geolocation.dart:46:24)
#5      _StopsAroundPageState.checkGPS (file:///Users/gaetan/Developer/tplusg/lib/views/tabs/around.da<…>

Am I doing something wrong ?

Error on build app

I cloned this git repo and tried to launch but I got this error please help

e: C:\Users\zakbl\Desktop\AndroidStudioProjects\geolocation\android\src\main\kotlin\app\loup\geolocation\GeolocationPlugin.kt: (78, 82): Unresolved reference: binaryMessenger
Finished with error: Gradle task assembleDebug failed with exit code 1

Android - currentLocation won't update location

calling currentLocation on the android emulator will return the last known location - and if a location is not available (eg if you turned off location and then turned it back on), it will return nothing.
It probably should in should try to get the location rather than failing without trying.

Also - in order to test out different locations I have to go to the maps app after changing the emulator location before currentLocation will pick up on the new location,.

I tried to use singleLocationUpdate on android but had the same issues. In light of the above, what is your advice If I want a single updated location.

Throws Exception in android

I/flutter (15786): The following PlatformException was thrown while invoking
I/flutter (15786): geolocation/location/addLocationUpdatesRequest:
I/flutter (15786): PlatformException(error, Expected BEGIN_OBJECT but was STRING at path $.options, null)```

background: true Has no effect

Hi I just want to understand what background option is for ? Because it feels like wheneve the app get paused by Android the location stream pause also where a timer function normally, I'm trying to get the location and update it on the map but if I press home or recent app for example, Geolocation.locationUpdates don't output anything. I'm am not talking about update when we close the app on the recent app list because its different from each app etc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.