Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build on Windows (desktop) #2298

Closed
2 tasks done
AtlasAutocode opened this issue Sep 25, 2024 · 12 comments
Closed
2 tasks done

Unable to build on Windows (desktop) #2298

AtlasAutocode opened this issue Sep 25, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@AtlasAutocode
Copy link

Downloaded your package and trying to build on Microsoft Windows using Android Studio.

Attempting to build your example app:
I was able to build when the target was the Edge browser.
I was unable to build when the target was Windows (desktop).

Received the following error message:

Nuget is not installed.
CMake Deprecation Warning at C:/Flutter/Projects/support/flutter_inappwebview-master/flutter_inappwebview_windows/example/build/windows/x64/_deps/googletest-src/CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Any assistance in fixing/resolving this problem will be appreciated.

  • I have read the Getting Started section
  • I have already searched for the same problem

Environment

Technology Version
Flutter version 3.24.1
Plugin version 6.1.0+1
Android version
iOS version
macOS version
Xcode version
Google Chrome version
Microsoft Windows 11

Device information: Windows desktop

Description

Expected behavior:
Example app builds.

Current behavior:
Does not build

Steps to reproduce

  1. Try to build the example app for Windows (desktop)

Images

Stacktrace/Logcat

@AtlasAutocode AtlasAutocode added the bug Something isn't working label Sep 25, 2024
Copy link

👋 @AtlasAutocode

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@pichillilorenzo
Copy link
Owner

As the error says Nuget is not installed., you need to install nuget on Windows, that is used to install the native dependencies and it should be available in your PATH Windows environment variable.

Follow the instructions here: https://learn.microsoft.com/en-us/nuget/install-nuget-client-tools?tabs=windows#nugetexe-cli

By the way, I still need to update the plugin docs for Windows on the website, as it was released just a few days ago.
There are other things to be aware of, for example: check the availability of the WebView2 Runtime, how to distribute your Windows app (if bundled or not with a specific WebView2 Runtime, etc... https://developer.microsoft.com/en-us/microsoft-edge/webview2/?form=MA13LH

@pichillilorenzo
Copy link
Owner

Just for reference: #460

@pichillilorenzo pichillilorenzo pinned this issue Sep 25, 2024
@AtlasAutocode
Copy link
Author

Thank you.
I use nuget all the time within Visual Studio so did not realize that it needs to be installed as an external program.

@pichillilorenzo
Copy link
Owner

The important thing is that nuget CLI tool should be available in the environment.
I don’t know if you are able to set the path of Visual Studio nuget instead of installing it as an external program 🤷🏻‍♂️.

@AtlasAutocode
Copy link
Author

Interestingly, I could not find nuget.exe anywhere so I assume Visual Studio 2022 is directly accessing using its own internal code.
I followed your help, downloaded nuget.exe and put it on my path.
Everything works great.
It's a small executable, only 8MB file, so no big deal.
Thanks for your help.

@pichillilorenzo
Copy link
Owner

Ok 👍

In this case I think that is only 8 MB because you are not including a fixed version of the WebView2 Runtime, so be aware to check the availability on the user side:

final availableVersion = await WebViewEnvironment.getAvailableVersion();

More about distribution: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution

Also, you should probably create a WebViewEnvironment to set a custom path for the userDataFolder:


The default user data folder of WebView2 is your_exe_file\WebView2, which is not a good place to store user data.
For example, if the application is installed in a read-only directory, the application will crash when WebView2 tries to write data.
After the creation, use it as the argument when you create an InAppWebView widget:

@EchoEllet
Copy link

If nuget is a requirement on the developer machine to build the flutter_inappwebview_windows, should this be documented in the README.md?

@pichillilorenzo
Copy link
Owner

@EchoEllet yes, but as I already said, I need to update the docs.
Give me some time and I will update it, probably today, thanks.

@EchoEllet
Copy link

Thank you for your efforts. Noticed REAMDE.md has been updated and this issue is addressed.

As a side note, when macOS and Windows support was introduced, they were added in 6.1.0 in a minor version, pub follow Semantic Versioning and assumed minor version (6.1.0 instead of 6.0.0) is compatible so it always uses the latest compatible version and it expects to build the project without any additional changes.

Since flutter_inappwebview is a complex plugin that requires platform setup and is being used by other plugins and packages, they also need to add notes there to indicate that additional steps required to build the project on desktop platforms with a reference to flutter_inappwebview since the error message can be generic and not quite clear. It can be a bit confusing for some of the users since their project was working without any changes to pubspec.yaml or even the code itself and once they run flutter pub get, they can't build the project anymore which is why you might noticed there are many related issues.

I would do one of the following:

  • Include a note, caution message in CHANGELOG.md and a temporary message in README.md indicating that additional steps are required for desktop support, maybe some checks in development mode before doing something that can throw such errors that are confusing. It also help ensure that other packages will require either older versions of flutter_inappwebview or they do the necessary changes to reflect those features.
  • Introduce a major release which is also considered a breaking change release, which require users, packages to update to 7.0.0 before they can use the package, this way we ensure they will read the CHANGELOG.md of 7.0.0, some packages might not be updated very early so if it uses 6.0.0 and some other package update to 7.0.0 or the user project use newer/older versions, a pubspc dependency conflict will happen, in general, sometimes I would avoid such solutions when possible since personally, I prefer to have that number 7 lower, even when it's a breaking change.

In short, support for macOS and Windows itself is a feature that's not a breaking change or can be considered a minor breaking change since it requires more steps to build the existing project.

Thank you for your time in fixing those issues and maintaining the project. I appreciate your help.

@pichillilorenzo
Copy link
Owner

@EchoEllet yes, you are right. I didn't though it could break the builds for macOS and Windows, as I wasn't changing the APIs of the plugin, so I considered it just as a minor change (just something new added).

Rightfully so, if an app had support for macOS or Windows, upgrading to the latest plugin version or plugin that uses it as a dependency, could have broken the build.
In this case, I think it could break only if your app has already support for macOS or Windows prior to the new 6.1.0 release.

Copy link

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 and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants