flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Geolocator fails to build for Windows

Open NickoftheSouth opened this issue 2 years ago • 1 comments

🐛 Bug Report

I've been trying to switch over to Geolocator due to its support for location on Windows, but the windows version will not build once the plugin is added.

It looks like I'm seeing a similar issue as this person; https://github.com/Baseflow/flutter-geolocator/issues/1001

I've tried with both Visual Studio 2019 and Visual Studio 2022, but got the same result. It complains about not being able to install the NuGet package Microsoft.Windows.CppWinRT.2.0.210806.1

Expected behaviour

Ability to build on windows using Visual Studio or 2019 - 2022

Reproduction steps

Added Geolocator the projects pubspec.yml file like so;

geolocator: ^9.0.1

Attempted to build for windows with the following installed;

  • Flutter
  • Visual Studio Community 2022

Then when trying to build for windows the flutter build system fails with the error;

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Nuget.exe not found, trying to download or use cached version.
Argument cannot be null or empty
Parameter name: primarySources
CMake Error at flutter/ephemeral/.plugin_symlinks/geolocator_windows/windows/CMakeLists.txt:33 (message):
  Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.210806.1


Exception: Unable to generate build files

note: I also tried to add nuget.exe which got rid of the first error, but still failed with the same issue.

Configuration

Version: ^9.0.1 Flutter Doctor output:

 flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.19044.1826], locale en-NZ)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
[√] Android Studio (version 2021.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!

Platform:

  • [√] Windows

NickoftheSouth avatar Aug 03 '22 04:08 NickoftheSouth

Hi @NickoftheSouth, I couldn't reproduce the same error on my machine.

When building the geolocator_windows/example/ app everything works as expected. In the issue you have linked there was a suggestion to update Visual Studio, then restart windows and proceed running flutter pub clean and flutter pub get in the project root.

Please also look at this issue for further reference.

Seeing that the build phase seems to work for me, I expect this to be a local configuration issue, please let me know if you still encounter this problem after these steps. Also make sure that you have nuget.exe added to your local variables.

YannickMaljaars avatar Sep 19 '22 11:09 YannickMaljaars

I am also getting the same error. Restarting/cleaning did not help

refectco avatar Mar 15 '23 00:03 refectco

Hi @NickoftheSouth, thank you for taking the time to report this issue!

As you mentioned getting the same error as #1001, I was wondering if you followed the steps mentioned in this comment. If you did, could you send us the output of the flutter doctor -v command and the exact version of the geolocator and geolocator_windows plugins you are using? These versions can be found in the pubspec.lock file.

JeroenWeener avatar Jun 19 '23 13:06 JeroenWeener

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] avatar Jul 03 '23 14:07 github-actions[bot]

Hi, i have been trying to build my flutter application for windows and facing same error.

debug logs
Launching lib\main.dart on Windows in debug mode...
main.dart:1
Argument cannot be null or empty
Parameter name: primarySources
CMake Error at flutter/ephemeral/.plugin_symlinks/geolocator_windows/windows/CMakeLists.txt:33 (message):
  Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.210806.1

Exception: Unable to generate build files
Exited (sigterm)

I have done all steps mentioned from the comment mentioned in the other issue (updating vs2022 with the required c++ environment, restarting windows, doing flutter clean and flutter pub get).

nuget version

NuGet Version: 6.6.1.2

These are the other information you asked in this issue thread above:

flutter doctor -v
[✓] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.22621.1992], locale en-IN)
    • Flutter version 3.10.6 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\Lenovo\AppData\Local\Android\Sdk
    • Platform android-33-ext4, build-tools 33.0.1
    • ANDROID_SDK_ROOT = C:\Users\Lenovo\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.6.33712.159
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[✓] VS Code, 64-bit edition (version 1.80.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.66.0

[✓] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1992]

[✓] Network resources
    • All expected network resources are available.

• No issues found!

these are my geolocator versions from pubspec.lock file

geolocator versions
  geolocator:
    dependency: "direct main"
    description:
      name: geolocator
      sha256: "5c23f3613f50586c0bbb2b8f970240ae66b3bd992088cf60dd5ee2e6f7dde3a8"
      url: "https://pub.dev"
    source: hosted
    version: "9.0.2"
  geolocator_android:
    dependency: transitive
    description:
      name: geolocator_android
      sha256: a8caf4801c24ed559c93410eb6bc7fce516e726e4267a2b34cfd4aa488309a7c
      url: "https://pub.dev"
    source: hosted
    version: "4.2.1"
  geolocator_apple:
    dependency: transitive
    description:
      name: geolocator_apple
      sha256: "36527c555f4c425f7d8fa8c7c07d67b78e3ff7590d40448051959e1860c1cfb4"
      url: "https://pub.dev"
    source: hosted
    version: "2.2.7"
  geolocator_platform_interface:
    dependency: transitive
    description:
      name: geolocator_platform_interface
      sha256: af4d69231452f9620718588f41acc4cb58312368716bfff2e92e770b46ce6386
      url: "https://pub.dev"
    source: hosted
    version: "4.0.7"
  geolocator_web:
    dependency: transitive
    description:
      name: geolocator_web
      sha256: f68a122da48fcfff68bbc9846bb0b74ef651afe84a1b1f6ec20939de4d6860e1
      url: "https://pub.dev"
    source: hosted
    version: "2.1.6"
  geolocator_windows:
    dependency: transitive
    description:
      name: geolocator_windows
      sha256: f5911c88e23f48b598dd506c7c19eff0e001645bdc03bb6fecb9f4549208354d
      url: "https://pub.dev"
    source: hosted
    version: "0.1.1"

Lemme know if more details are needed

milindgoel15 avatar Aug 01 '23 10:08 milindgoel15