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.38k stars 27.28k forks source link

Building Windows UWP application failed #82967

Closed liudonghua123 closed 3 years ago

liudonghua123 commented 3 years ago

Steps to Reproduce

I noticed windows uwp is already supported (https://github.com/flutter/flutter/pull/82373, https://github.com/flutter/flutter/issues/82085), maybe at some experimental level. So I tried to build a sample uwp example app.

  1. Run flutter channel master && flutter upgrade
  2. Run flutter config --enable-windows-uwp-desktop
  3. Run flutter create hello_uwp.
  4. Run cd flutter_uwp && flutter run -d winuwp

Expected results: Works as expected.

Actual results: Build failed as the following picture shown.

image

Logs ``` D:\code\flutter\hello_uwp>flutter run -d winuwp Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Downloading windows-x64-debug/windows-uwp-x64-flutter tools... 24.6s Downloading windows-x64/flutter-cpp-client-wrapper tools... 1,364ms Downloading windows-x64-profile/windows-uwp-x64-flutter tools... 18.6s Downloading windows-x64-release/windows-uwp-x64-flutter tools... 11.6s Launching lib\main.dart on Windows (UWP) in debug mode... D:\code\flutter\hello_uwp\winuwp\flutter\ephemeral\cpp_client_wrapper\flutter_view_controller.cc(17,17): error C3861: 'FlutterDesktopViewControllerCreateFromCoreWindow': identifier not found [D:\code\flutter\hello_uwp\build\winuwp\flutter\flutter_wrapper_app.vcxproj] C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml" task returned false but did not log an error. [D:\code\flutter\hello_uwp\build\winuwp\flutter\flutter_wrapper_app.vcxproj] Building Windows UWP application... Exception: Build process failed. D:\code\flutter\hello_uwp> ``` ``` D:\code\flutter\hello_uwp>flutter analyze Analyzing hello_uwp... No issues found! (ran in 161.0s) D:\code\flutter\hello_uwp> ``` ``` D:\code\flutter\hello_uwp>flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 2.3.0-13.0.pre.48, on Microsoft Windows [Version 10.0.19042.985], locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc3) [✓] Chrome - develop for the web [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.0) [✓] Android Studio (version 4.2.0) [✓] IntelliJ IDEA Ultimate Edition (version 2021.1) [✓] VS Code, 32-bit edition (version 1.56.2) [✓] Connected device (4 available) • No issues found! D:\code\flutter\hello_uwp> ```
stuartmorgan commented 3 years ago

Duplicate of https://github.com/flutter/flutter/issues/82723

liudonghua123 commented 3 years ago

I found maybe it was releated to https://github.com/flutter/flutter/issues/82723, so I tried jonahwilliams's patch.

D:\apps\flutter>git remote add jonahwilliams git@github.com:jonahwilliams/flutter.git

D:\apps\flutter>git pull jonahwilliams use_correct_artifact
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 22 (delta 19), reused 22 (delta 19), pack-reused 0
Unpacking objects: 100% (22/22), done.
From github.com:jonahwilliams/flutter
 * branch                  use_correct_artifact -> FETCH_HEAD
 * [new branch]            use_correct_artifact -> jonahwilliams/use_correct_artifact
Merge made by the 'recursive' strategy.
 packages/flutter_tools/lib/src/artifacts.dart                    | 9 ++++++++-
 packages/flutter_tools/lib/src/build_system/targets/windows.dart | 2 +-
 .../test/general.shard/build_system/targets/windows_test.dart    | 2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

D:\apps\flutter>
D:\code\flutter\hello_uwp>flutter run -d winuwp
Launching lib\main.dart on Windows (UWP) in debug mode...
D:\code\flutter\hello_uwp\winuwp\flutter\ephemeral\cpp_client_wrapper\flutter_view_controller.cc(17,17): error C3861: 'FlutterDesktopViewControllerCreateFromCoreWindow': identifier not found [D:\code\flutter\hello_uwp\build\winuwp\flutter\flutter_wrapper_app.vcxproj]
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml" task returned false but did not log an error. [D:\code\flutter\hello_uwp\build\winuwp\flutter\flutter_wrapper_app.vcxproj]
Building Windows UWP application...
Exception: Build process failed.

D:\code\flutter\hello_uwp>flutter run -d winuwp
Building flutter tool...
Running pub upgrade...
Resolving dependencies...
  _fe_analyzer_shared 21.0.0
  analyzer 1.5.0
  archive 3.1.2
  args 2.1.0
  async 2.6.1
  boolean_selector 2.1.0
  browser_launcher 1.0.0
  built_collection 4.3.2 (5.0.0 available)
  built_value 7.1.0 (8.0.6 available)
  charcode 1.2.0
  checked_yaml 2.0.1
  cli_util 0.3.0
  clock 1.1.0
  collection 1.15.0
  completion 1.0.0
  convert 3.0.0
  coverage 1.0.2
  crypto 3.0.1
  csslib 0.17.0
  dds 1.7.6 (1.8.0 available)
  dwds 11.0.2
  fake_async 1.2.0
  ffi 1.0.0
  file 6.1.1
  file_testing 3.0.0
  fixnum 0.10.11 (1.0.0 available)
  flutter_template_images 3.0.0
  glob 2.0.1
  html 0.15.0
  http 0.13.3
  http_multi_server 3.0.1
  http_parser 4.0.0
  intl 0.17.0
  io 1.0.0
  js 0.6.3
  json_annotation 4.0.1
  json_rpc_2 2.2.2 (3.0.1 available)
  logging 1.0.1
  matcher 0.12.10
  meta 1.3.0
  mime 1.0.0
  mockito 4.1.1+1 (5.0.8 available)
  multicast_dns 0.3.0
  mustache_template 2.0.0
  native_stack_traces 0.4.0
  node_preamble 2.0.0
  package_config 2.0.0
  path 1.8.0
  pedantic 1.11.0
  petitparser 4.1.0
  platform 3.0.0
  pool 1.5.0
  process 4.2.1
  pub_semver 2.0.0
  pubspec_parse 1.0.0
  quiver 2.1.5 (3.0.1 available)
  shelf 1.1.4
  shelf_packages_handler 3.0.0
  shelf_proxy 1.0.0
  shelf_static 1.0.0
  shelf_web_socket 1.0.1
  source_map_stack_trace 2.1.0
  source_maps 0.10.10
  source_span 1.8.1
  sse 3.8.3 (4.0.0 available)
  stack_trace 1.10.0
  stream_channel 2.1.0
  string_scanner 1.1.0
  sync_http 0.3.0
  term_glyph 1.2.0
  test 1.16.8 (1.17.4 available)
  test_api 0.3.0 (0.4.0 available)
  test_core 0.3.19 (0.3.24 available)
  typed_data 1.3.0
  usage 4.0.2
  uuid 3.0.4
  vm_service 6.2.0 (7.0.0 available)
  vm_snapshot_analysis 0.7.0
  watcher 1.0.0
  web_socket_channel 2.1.0
  webdriver 3.0.0
  webkit_inspection_protocol 1.0.0
  win32 2.0.5 (2.1.1 available)
  xml 5.1.0
  yaml 3.1.0
No dependencies changed.
13 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
Running "flutter pub get" in hello_uwp...                        1,709ms
Launching lib\main.dart on Windows (UWP) in debug mode...
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\code\flutter\hello_uwp\build\winuwp\runner_uwp\app.vcxproj]
Building Windows UWP application...
Install developer certificate.

Windows UWP apps are signed with a developer certificate during the build
process. On the first install of an app with a signature from a new
certificate, the certificate must be installed.

If desired, this certificate can later be removed by launching the
"Manage Computer Certificates" control panel from the Start menu and deleting
the "CMake Test Cert" certificate from the "Trusted People" > "Certificates"
section.

Press "Y" to continue, or "N" to cancel.: Y
Failed to install
file:///D:/code/flutter/hello_uwp/build/winuwp/runner_uwp/AppPackages/app/app_1.1.0.0_x64_Debug_Test/app_1.1.0.0_x64_Debug.msix
Failed to install app package
Error launching application on Windows (UWP).

D:\code\flutter\hello_uwp>

Now it seems to build success, build still failed to run it.

liudonghua123 commented 3 years ago

I also tried to manually install the generated app (D:/code/flutter/hello_uwp/build/winuwp/runner_uwp/AppPackages/app/app_1.1.0.0_x64_Debug_Test/app_1.1.0.0_x64_Debug.msix).

image

liudonghua123 commented 3 years ago

I found maybe I missing some debug version of vclibs. So I tried --release flag.

D:\code\flutter\hello_uwp>flutter run -d winuwp  --release
Launching lib\main.dart on Windows (UWP) in release mode...
Building Windows UWP application...
Failed to locate app package to install
Failed to install app package
Error running application on Windows (UWP).

D:\code\flutter\hello_uwp>flutter build winuwp  --release

💪 Building with sound null safety 💪

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3326,5): warning : APPX4001: Build property AppxBundlePlatforms is not explicitly set and is calculated based on currently building architecture. Use 'Create App Package' wizard or edit project file to set it. [D:\code\flutter\hello_uwp\build\winuwp\runner_uwp\app.vcxproj]
Building Windows UWP application...

D:\code\flutter\hello_uwp>

Then I installed D:\code\flutter\hello_uwp\build\winuwp\runner_uwp\AppPackages\app\app_1.1.0.0_Test\app_1.1.0.0_x64.msixbundle successfully finally.

However, I checked the Windows Kits, I found I have Microsoft.VCLibs.x64.Debug.14.00.Desktop.appx in C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Debug\x64 indeed. That's really strange.

image

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.