flutter编译
855 2024-10-25 11:12
在 Windows 桌面平台上,以“详细日志”模式启动你的 Flutter 应用。
flutter run -d windows -v
把你的 Flutter 项目 编译成可上架、可分发的 Windows Release 版本,输出一套完整的 .exe + .dll + data 文件夹 运行体
flutter build windows
升级插件
flutter pub upgrade
flutter clean
flutter pub get
错误:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Please set "hierarchicalLoggingEnabled" to true if you want to change the level on a non-root logger.
答案:
这个错误信息表明你正在尝试更改非根记录器的日志级别,但是没有启用层次化日志记录。在Flutter中,如果你想对特定记录器进行更细粒度的日志级别控制,你需要将hierarchicalLoggingEnabled
设置为true
。
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> flutter clean
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Deleting build... 41ms
Deleting .dart_tool... 2ms
Deleting Generated.xcconfig... 1ms
Deleting flutter_export_environment.sh... 1ms
Deleting ephemeral... 1ms
Deleting ephemeral... 0ms
Deleting ephemeral... 1ms
Deleting .flutter-plugins-dependencies... 0ms
Deleting .flutter-plugins... 0ms
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> flutter pub get
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Resolving dependencies...
Downloading packages...
Warning: Unable to fetch advisories for "archive" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
Warning: Unable to fetch advisories for "http" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
Warning: Unable to fetch advisories for "shared_preferences_android" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
archive 3.6.1 (4.0.7 available)
args 2.6.0 (2.7.0 available)
async 2.11.0 (2.13.0 available)
audioplayers 5.2.1 (6.5.1 available)
audioplayers_android 4.0.3 (5.2.1 available)
audioplayers_darwin 5.0.2 (6.3.0 available)
audioplayers_linux 3.1.0 (4.2.1 available)
audioplayers_platform_interface 6.1.0 (7.1.1 available)
audioplayers_web 4.1.0 (5.1.1 available)
audioplayers_windows 3.1.0 (4.2.1 available)
boolean_selector 2.1.1 (2.1.2 available)
cchess 0.0.4 (0.0.7 available)
characters 1.3.0 (1.4.1 available)
charcode 1.3.1 (1.4.0 available)
clock 1.1.1 (1.1.2 available)
collection 1.18.0 (1.19.1 available)
csslib 1.0.0 (1.0.2 available)
fake_async 1.3.1 (1.3.3 available)
ffi 2.1.3 (2.1.4 available)
file_picker 6.2.1 (10.3.3 available)
flutter_lints 5.0.0 (6.0.0 available)
flutter_native_splash 2.4.2 (2.4.6 available)
flutter_plugin_android_lifecycle 2.0.23 (2.0.30 available)
html 0.15.4 (0.15.6 available)
http 1.2.2 (1.5.0 available)
http_parser 4.0.2 (4.1.2 available)
icons_launcher 2.1.7 (3.0.2 available)
image 4.3.0 (4.5.4 available)
intl 0.19.0 (0.20.2 available)
js 0.6.8 (retracted, 0.7.2 available)
leak_tracker 10.0.5 (11.0.2 available)
leak_tracker_flutter_testing 3.0.5 (3.0.10 available)
leak_tracker_testing 3.0.1 (3.0.2 available)
lints 5.0.0 (6.0.0 available)
matcher 0.12.16+1 (0.12.17 available)
material_color_utilities 0.11.1 (0.13.0 available)
meta 1.15.0 (1.17.0 available)
path 1.9.0 (1.9.1 available)
path_provider 2.1.4 (2.1.5 available)
path_provider_android 2.2.12 (2.2.18 available)
path_provider_foundation 2.4.0 (2.4.2 available)
petitparser 6.0.2 (7.0.1 available)
shared_preferences 2.3.2 (2.5.3 available)
shared_preferences_android 2.3.3 (2.4.12 available)
shared_preferences_foundation 2.5.3 (2.5.4 available)
shared_preferences_web 2.4.2 (2.4.3 available)
shirne_dialog 4.8.2 (4.8.5 available)
source_span 1.10.0 (1.10.1 available)
stack_trace 1.11.1 (1.12.1 available)
stream_channel 2.1.2 (2.1.4 available)
string_scanner 1.2.0 (1.4.1 available)
synchronized 3.3.0+3 (3.4.0 available)
test_api 0.7.2 (0.7.7 available)
vector_math 2.1.4 (2.2.0 available)
vm_service 14.2.5 (15.0.2 available)
web 1.1.0 (1.1.1 available)
win32 5.7.1 (5.14.0 available)
window_manager 0.4.3 (0.5.1 available)
xml 6.5.0 (6.6.1 available)
yaml 3.1.2 (3.1.3 available)
Got dependencies!
61 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> flutter build windows --release
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
CMake Error at CMakeLists.txt:53 (add_subdirectory):
add_subdirectory given source "runner" which is not an existing directory.
CMake Error at flutter/generated_plugins.cmake:18 (target_link_libraries):
Cannot specify link libraries for target "chinese_chess" which is not built
by this project.
Call Stack (most recent call first):
CMakeLists.txt:57 (include)
Building Windows application... 14.0s
Unable to generate build files
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> flutter create . --platforms=windows
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Recreating project ....
.idea\libraries\Dart_SDK.xml (created)
.idea\libraries\KotlinJavaRuntime.xml (created)
.idea\modules.xml (created)
.idea\workspace.xml (created)
chinese_chess.iml (created)
windows\runner\CMakeLists.txt (created)
windows\runner\flutter_window.cpp (created)
windows\runner\flutter_window.h (created)
windows\runner\main.cpp (created)
windows\runner\resource.h (created)
windows\runner\resources\app_icon.ico (created)
windows\runner\runner.exe.manifest (created)
windows\runner\Runner.rc (created)
windows\runner\utils.cpp (created)
windows\runner\utils.h (created)
windows\runner\win32_window.cpp (created)
windows\runner\win32_window.h (created)
Resolving dependencies...
Downloading packages...
Warning: Unable to fetch advisories for "archive" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
Warning: Unable to fetch advisories for "http" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
Warning: Unable to fetch advisories for "shared_preferences_android" from "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/".
Got dependencies.
Wrote 18 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd .
$ flutter run
Your application code is in .\lib\main.dart.
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> ls windows/runner
目录: E:\Users\Administrator\FlutterProjects\chinese_chess\windows\runner
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2025/9/18 21:53 resources
-a---- 2024/9/13 1:21 1836 CMakeLists.txt
-a---- 2024/9/13 1:21 2193 flutter_window.cpp
-a---- 2024/9/13 1:21 961 flutter_window.h
-a---- 2025/9/18 21:53 1309 main.cpp
-a---- 2024/9/13 1:21 448 resource.h
-a---- 2024/9/13 1:21 616 runner.exe.manifest
-a---- 2025/9/18 21:53 3168 Runner.rc
-a---- 2024/9/13 1:21 1862 utils.cpp
-a---- 2024/9/13 1:21 691 utils.h
-a---- 2024/9/13 1:21 8822 win32_window.cpp
-a---- 2024/9/13 1:21 3624 win32_window.h
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess> flutter build windows --release
Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Building Windows application... 73.6s
√ Built build\windows\x64\runner\Release\chinese_chess.exe
(python311) PS E:\Users\Administrator\FlutterProjects\chinese_chess>
全部评论