我刚接触flutter,我想让默认的flutter应用程序出现在我的Android模拟器上。模拟器启动正常,但在“gradle task assembleDebug”时过程失败。我重新安装了从Android Studio到flutter和dart的所有内容,并从Android Studio中删除了AVD,然后再次创建它,但似乎没有任何效果。我尝试了一些来自youtube和谷歌搜索的潜在修复,包括在根目录下运行“gradle包装器”命令,但这也不起作用,因为所有flutter应用程序的根目录都缺少“build. gradle”文件。Flutter医生没有显示任何问题。
“flutter医生”命令输出:
PS C:\Users\Mahmud Alam\Desktop\Programming Stuff\Flutter&Dart\newproj\firstapp> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.22000.675], locale en-US)
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.10)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.2)
[√] Connected device (4 available)
[√] HTTP Host Availability
• No issues found!
命令行中的错误输出:
PS C:\Users\Mahmud Alam\Desktop\Programming Stuff\Flutter&Dart\newproj\firstapp> flutter run
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
'Dart\newproj\firstapp\android\' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
Running Gradle task 'assembleDebug'... 19.6s
Exception: Gradle task assembleDebug failed with exit code 1
我觉得某处丢失了一些东西,但我不知道在哪里以及如何恢复丢失的文件。此外,我正在运行Pixel 2API30(android x86)的仿真。但这本身不应该造成任何问题。我该如何解决这个问题?
编辑:[文件夹结构截图]
我想这是你的"
尝试在您的终端中运行flutter清洁
,然后重建应用程序,这在过去对我有用。
这些步骤对我有用。