flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.7k stars 27.36k forks source link

Flutter generates an error when running on windows desktop #157437

Open Junkmer opened 2 days ago

Junkmer commented 2 days ago

Steps to reproduce

Now here's the question

I have downloaded and configured the flutter windows desktop environment, running flutter doctor is also normal, creating a new project after selecting the desktop will also work, but when I add any third party plugins in pubspec.yaml, running the following error, How should I solve this problem, or how to troubleshoot it


Flutter 3.22.3 • channel [user-branch] • unknown source
Framework • revision b0850beeb2 (3 months ago) • 2024-07-16 21:43:41 -0700
Engine • revision 235db911ba
Tools • Dart 3.4.4 • DevTools 2.34.3

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.22.3, on Microsoft Windows [版本 10.0.22631.4169], locale zh-CN)
    ! Flutter version 3.22.3 on channel [user-branch] at D:\Junker\Flutter\flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at
      https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not the same as FLUTTER_GIT_URL
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.11.5)
[√] Android Studio (version 2024.1)
[√] Connected device (3 available)
[√] Network resources

Actual results

image

image

Logs

Logs ```console ```

Flutter Doctor output

Doctor output ```console ```
darshankawar commented 1 day ago

@Junkmer Looking at the error you are getting, it may be related to your local pub cache and not in the plugin itself. Looks like damaged pub cache, where package versions are missing files in your cache. Try running flutter pub cache repair to see if it helps or not.

Junkmer commented 1 day ago

Ok, I will try to run it later and check it. Thank you very much

Junkmer commented 1 day ago

I tried it according to your suggestion, but found it was not successful, the same error was still reported, and there would be an error when adding any third-party library image

PS D:\xxxx\FlutterProjects\self-project\test-flutter-project> flutter clean Deleting build... 8ms Deleting .dart_tool... 1ms Deleting Generated.xcconfig... 0ms Deleting flutter_export_environment.sh... 0ms Deleting ephemeral... 0ms Deleting ephemeral... 0ms Deleting ephemeral... 0ms Deleting .flutter-plugins-dependencies... 0ms Deleting .flutter-plugins... 0ms PS D:\xxxx\FlutterProjects\self-project\test-flutter-project> flutter pub cache repair Reinstalled 660 packages. PS D:\xxxx\FlutterProjects\self-project\test-flutter-project> flutter pub get Resolving dependencies... Downloading packages... async 2.11.0 (2.12.0 available) boolean_selector 2.1.1 (2.1.2 available) characters 1.3.0 (1.3.1 available) collection 1.19.0 (1.19.1 available) fake_async 1.3.1 (1.3.2 available) flutter_lints 3.0.2 (5.0.0 available) js 0.6.7 (0.7.1 available) leak_tracker 10.0.5 (10.0.8 available) leak_tracker_flutter_testing 3.0.5 (3.0.9 available) lints 3.0.0 (5.1.0 available) matcher 0.12.16+1 (0.12.17 available) material_color_utilities 0.11.1 (0.12.0 available) meta 1.15.0 (1.16.0 available) path 1.9.0 (1.9.1 available) path_provider_android 2.2.10 (2.2.12 available) stack_trace 1.11.1 (1.12.0 available) string_scanner 1.3.0 (1.4.0 available) vm_service 14.2.4 (14.3.1 available) Got dependencies! 18 packages have newer versions incompatible with dependency constraints. Try flutter pub outdated for more information. PS D:\xxxx\FlutterProjects\self-project\test-flutter-project> flutter run -d windows Launching lib\main.dart on Windows in debug mode... CMake Error at flutter/generated_plugins.cmake:15 (add_subdirectory): add_subdirectory given source "flutter/ephemeral/.plugin_symlinks/tencent_cloud_chat_sdk/windows" which is not an existing directory. Call Stack (most recent call first): CMakeLists.txt:59 (include)

Building Windows application... 4.0s Error: Unable to generate build files

darshankawar commented 8 hours ago

@Junkmer Is it only occuring while trying to add the said third party package or any third party package results in same error ?

Junkmer commented 7 hours ago

That's right. Just add any plugin and you'll get the same error.

Added: 1, Create Flutter project, do not add any third-party libraries, select windows(desktop) can run successfully 2, add any third-party library, as long as you do not select "window(desktop)" can run successfully

I wonder if there is something wrong with my cmake, but I am running the im Android project with the cmake configuration as normal

This problem has been bothering me for a few days, I tried to upgrade the windows system, upgrade the Flutter version, upgrade the cmake version and couldn't solve it

Junkmer commented 7 hours ago

If you have any points that you might suspect, just bring them up, I try as much as I can, I look up similar anomalies online, and there is no solution I want

https://github.com/flutter/flutter/issues/141514

This is the only one similar to mine, I have tried it, neither Powershell nor cmd will work

Also run vs code, same error

darshankawar commented 1 hour ago

Currently on an unknown channel. Run flutter channel to switch to an official channel.

Can you switch to official channel as suggested and try again to check if it still persist ?