gpt4 book ai didi

flutter - 无法在Android Studio中运行Flutter应用

转载 作者:行者123 更新时间:2023-12-03 03:32:28 27 4
gpt4 key购买 nike

我创建了一个新的flutter项目,运行该项目时出现该错误

Target kernel_snapshot failed: Exception: The value of -DDartDefines is not formatted correctly.
The value must be a JSON-encoded list of strings but was:
[flutter.inspector.structuredErrors=true]
build failed.

FAILURE: Build failed with an exception.

* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Exception: Gradle task assembleDebug failed with exit code 1
我试过 flutter 干净,并且出现同样的错误
flutter 医生日志:
D:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
• Flutter version 1.16.4-pre.69 at D:\flutter
• Framework revision 19e7db585d (4 months ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[!] VS Code (version 1.47.2)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Connected device
! No devices available

! Doctor found issues in 3 categories.
Process finished with exit code 0

最佳答案

根据flutter医生给您的提示,问题可能与未安装Android Android SDK或未正确配置有关:
Flutter提供了更新Android SDK路径的命令:

flutter config --android-sdk <path-to-your-android-sdk-path>
您可以直接从Android Studio安装它:
要从Android Studio打开SDK Manager,请单击工具> SDK Manager或在工具栏中单击SDK Manager。您可能必须取消选中“隐藏过时的软件包”并安装被视为过时的软件包。
或者,您可以从此链接安装它并按照我之前说的进行配置:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://android-sdk.fr.uptodown.com/windows&ved=2ahUKEwi-itWCkuzqAhXTZTUKHa29CRMQFjACegQIAhAB&usg=AOvVaw1QSSVVMrZzFltXvboDbTeQ

关于flutter - 无法在Android Studio中运行Flutter应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63106833/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com