[英]Flutter's main.dart file gets stuck at "Syncing files to device Android SDK built for x86 64..." at execution in Android Studio
I am trying out my first ever flutter code on Android Studio and I am displaying it on an emulator.我正在 Android Studio 上尝试我的第一个 flutter 代码,并在模拟器上显示它。 I do get the output but the compilation never ends, which means I cannot Hot Restart my code.我确实得到了输出,但编译永远不会结束,这意味着我无法热重启我的代码。 The tutorial I am learning from isn't getting this problem.我正在学习的教程没有遇到这个问题。
EDIT : Some new errors arose.编辑:出现了一些新错误。 It started hanging at "Installing build\\app\\outputs\\apk\\app.apk", I solved that issue and now it displays this.它开始挂在“安装 build\\app\\outputs\\apk\\app.apk”,我解决了这个问题,现在它显示了这个。 It is intermittent, the skipped frame and lines interchange but more or less the problem remains the same.它是间歇性的,跳帧和行互换,但或多或少问题仍然存在。 Please help am going crazy over solving it :)请帮助我疯狂解决它:)
The following code appears:出现以下代码:
Launching lib\main.dart on Android SDK built for x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Syncing files to device Android SDK built for x86 64...
I/Choreographer( 5985): Skipped 61 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 5985): eglMakeCurrent: 0x7e7ece03e300: ver 3 0 (tinfo 0x7e7ece1a85e0)
I/OpenGLRenderer( 5985): Davey! duration=1554ms; Flags=1, IntendedVsync=1503595359014, Vsync=1504612025640, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1504619561700, AnimationStart=1504619633200, PerformTraversalsStart=1504619653300, DrawStart=1504626010200, SyncQueued=1504626824700, SyncStart=1504630541800, IssueDrawCommandsStart=1504630721200, SwapBuffers=1504690106800, FrameCompleted=1505153649500, DequeueBufferDuration=49170000, QueueBufferDuration=2336000,
D/EGL_emulation( 5985): eglMakeCurrent: 0x7e7ecc6fa7e0: ver 3 0 (tinfo 0x7e7ecc62baa0)
Syncing files to device Android SDK built for x86 64...
Well, it seems on Linux that's because of some changes in kernel 5.5.嗯,在 Linux 上似乎是因为内核 5.5 中的一些更改。 I tested multiple times and I am sure - on kernel 5.4 it works, but on kernel 5.5 refactoring hangs and also debug does not work.我测试了多次,我确信 - 在内核 5.4 上它可以工作,但在内核 5.5 上重构挂起并且调试也不起作用。
That's strange, I have no idea how is is related to kernel (refactoring? wtf?), I can suspect some changes in filsestem handling could cause that?这很奇怪,我不知道与内核(重构?wtf?)有什么关系,我可以怀疑 filsestem 处理中的一些变化可能导致这种情况? Need to create bug report to InteliJ or Flutter and tell them new kernel causes problem.需要向 InteliJ 或 Flutter 创建错误报告并告诉他们新内核导致问题。
Also strange, when developing in Java/Kotlin with Android Studio, I have no problems, refactoring and debug both work just fine.同样奇怪的是,在使用 Android Studio 在 Java/Kotlin 中进行开发时,我没有任何问题,重构和调试都可以正常工作。 So this must be related to Flutter.所以这肯定和Flutter有关。
So, on Linux need to downgrade kernel to 5.4 for now (no idea about Mac or Win).因此,在 Linux 上,现在需要将内核降级到 5.4(不知道 Mac 或 Win)。
Put this statement right after the beginning of main function.将此语句放在 main 函数开始之后。
WidgetsFlutterBinding.ensureInitialized();
And then restart the application.然后重新启动应用程序。
当我没有连接到网络时,我遇到了这个问题。我是第一次运行那个项目。所以检查你的互联网并重新启动应用程序几次,它会运行得很快
I have an exactly same issue on linux5.5 kernel.我在 linux5.5 内核上有一个完全相同的问题。
inxi印西
CPU: Quad Core AMD Ryzen 3 PRO 3300U w/ Radeon Vega Mobile Gfx (-MCP-)
speed/max: 1397/1400 MHz Kernel: 5.5.2-1-MANJARO x86_64 Up: 1d 4h 05m
Mem: 12541.8/22014.1 MiB (57.0%) Storage: 476.94 GiB (15.3% used) Procs: 332
Shell: fish 3.0.2 inxi: 3.0.37
flutter doctor扑医生
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)
• No issues found!
Only agreeing with user1209216 .只同意user1209216 。
Using Visual Studio, execution was stuck on "Syncing files to device" while using kernel-5.5.8-200.fc31.使用 Visual Studio,在使用 kernel-5.5.8-200.fc31 时,执行卡在“将文件同步到设备”上。
I downgraded to kernel-5.3.7-301.fc31 and was able to launch a Flutter app on an emulator and a physical device.我降级到 kernel-5.3.7-301.fc31 并且能够在模拟器和物理设备上启动 Flutter 应用程序。
See also: https://github.com/flutter/flutter/issues/另见: https : //github.com/flutter/flutter/issues/
You can either downgrade to a previous kernel until a new version of Flutter is released on the stable channel or run flutter channel master
.您可以降级到以前的内核,直到在稳定频道上发布新版本的 Flutter 或运行flutter channel master
。
More information on how Flutter structures their release channels: https://github.com/flutter/flutter/wiki/Flutter-build-release-channels有关 Flutter 如何构建发布渠道的更多信息: https : //github.com/flutter/flutter/wiki/Flutter-build-release-channels
I was facing the same error in my Fedora which is running on the Linux kernel (5.11).我在 Linux 内核 (5.11) 上运行的 Fedora 中遇到了同样的错误。 I tried several things but nothing worked.我尝试了几件事,但没有任何效果。 It was taking 2-3 forced restart to finish the build.完成构建需要 2-3 次强制重启。
I downgraded the emulator API from API level 30 (x86) to API level 28 (x86_64) now it is working seamlessly on my machine.我将模拟器 API 从 API 级别 30 (x86) 降级到 API 级别 28 (x86_64) 现在它可以在我的机器上无缝运行。 Build of a small app only takes 1 minute or so.构建一个小应用程序只需要 1 分钟左右。 If nothing worked for you, therefore, you may try downgrading the API level of the emulator.因此,如果没有任何效果,您可以尝试降级模拟器的 API 级别。
I had the same situation today, and took me a few hours to find out the solution, and it was very simple.我今天遇到了同样的情况,花了我几个小时才找到解决方案,而且很简单。
I basically started building a loop, then got distracted with something else, and forgot to delete it.我基本上开始构建一个循环,然后被其他东西分心,忘记删除它。
So what caused my "Syncing files to device" not to finish, and my initial page to freeze, was this.那么是什么导致我的“同步文件到设备”没有完成,并且我的初始页面冻结,就是这个。 I had an infinite loop in my Home initState.我的 Home initState 中有一个无限循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.