“Flutter项目在调试模式下无法运行”

huangapple go评论63阅读模式
英文:

Flutter Project does not work on debug mode

问题

我有一个项目,在更新Flutter后,当我从Android Studio的调试按钮运行我的应用程序时,出现了一个奇怪的错误。

当前的Flutter SDK版本是3.3.5。

因为doki_app依赖于fluent_ui >=4.3.0,需要Flutter SDK版本>=3.7.0,所以版本解决失败。

但是当我从终端运行它时,一切都正常。

[✓] Flutter(通道稳定,3.7.10,在macOS 12.6 21G115 darwin-arm64上,区域设置为en-IR)

英文:

I have a project which was working fine but after updating Flutter I find a weird error when I run my app from the Android studio debug button

The current Flutter SDK version is 3.3.5.

Because doki_app depends on fluent_ui >=4.3.0 which requires Flutter SDK version  
>=3.7.0, version solving failed.

but when I run it from the terminal every thing works fine.

[✓] Flutter (Channel stable, 3.7.10, on macOS 12.6 21G115 darwin-arm64, locale en-IR)

答案1

得分: 1

我猜测你的计算机上安装了两个不同版本的Flutter,分别是3.3.53.7.10。这可能是因为你的IDE有自己的设置,以确定应该在哪里查找Flutter SDK,这就是你所描述的current SDK version所使用的内容。

从终端运行flutter命令时,它使用你的PATH环境变量来搜索与你的命令名称匹配的可执行文件。

所以我猜测你的IDEPATH环境变量指向你计算机上的两个不同的Flutter安装。

因此,要解决这个问题,你需要更新你的PATH环境变量,以指向正确的版本。理想情况下,你应该将其指向更新的3.7.10,如果你计划使用fluent_ui >= 4.3.0的话。

英文:

I guess that you have two different versions of Flutter namely 3.3.5 and 3.7.10 installed on your computer. This is possible because your IDE has its own setting to know where it should look for Flutter SDK which is what is being used as described by your current SDK version

From the terminal when you are running the flutter command it uses your PATH environment variable to search for an executable matching your command name.

So my guess is that your IDE and PATH environment variable points to two different Flutter installations on your computer.

Hence, to solve this you need to either update your PATH environment variable to point to the correct version. Ideally you will need to point it to the more latest 3.7.10 if your planning on using fluent_ui >= 4.3.0

答案2

得分: 1

在您的计算机上似乎安装了多个Flutter SDK版本。在终端中,您默认的Flutter版本是3.7.10。在您的Android Studio中,似乎安装了Flutter版本3.3.5,这就是为什么您会遇到以下错误:

doki_app依赖于fluent_ui >=4.3.0,要求Flutter SDK版本 >=3.7.0,版本解决失败。

请确保在Android Studio中选择了Flutter 3.7.10。

英文:

It seems like you are have multiple flutter SDK versions installed on your computer.
In terminal you have default Flutter version 3.7.10.
In your Android Studio it seems like you have Flutter version 3.3.5, that's why you get an error:

doki_app depends on fluent_ui >=4.3.0 which requires Flutter SDK version  
>=3.7.0, version solving failed.

Make sure you have Flutter 3.7.10 selected on your Anroid Studio as well.

答案3

得分: 0

请打开您项目中的 pubspec.lock 文件,然后搜索 sdks 一词,然后根据您的计算机上的 dartflutter 版本更改它们的版本。

sdks:
  dart: ">=2.19.2 <3.0.0"
  flutter: ">=3.7.0"

重新启动 IDE 或计算机将会使其更好。

英文:

Go to pubspec.lock file in your project and search for sdks term, then change both the dart and flutter versions due to your machine's dart and flutter versions.

sdks:
  dart: &quot;&gt;=2.19.2 &lt;3.0.0&quot;
  flutter: &quot;&gt;=3.7.0&quot;

An IDE or PC restart will make it better.

答案4

得分: 0

运行以下命令:

flutter clean

然后

flutter pub upgrade

然后

flutter clean

然后

flutter run

如果仍然不起作用,请运行此命令

flutter run --no-sound-null-safety
英文:

run

flutter clean

then

flutter pub upgrade 

then

flutter clean

then

flutter run

if still not works run this command

flutter run --no-sound-null-safety

huangapple
  • 本文由 发表于 2023年4月13日 16:38:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003369.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定