Flutter run (syncing files) does not finish
The flutter build/sync process does not finish for me. It's stuck at Syncing files to device Android SDK built for x86...
.
The issue happens with every app and is not connected to the emulator itself, since even a physical device (Nexus 5X) has the same problem.
For cempletions sake the emulator was created with flutter emulators --create --name nexus
My main problem is being unable to use hot-reload, debugging tools and other features. How could I further investigate/debug?
Console only
- Compilation and execution works fine
- App is responsive and console print statements work, with console output.
flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.8 at /home/jannik/devenv/flutter
• Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/jannik/devenv/android-sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/jannik/devenv/android-sdk
• ANDROID_SDK_ROOT = /home/jannik/devenv/android-sdk
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_232-solus-ga)
• All Android licenses accepted.
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
! Doctor found issues in 1 category.
flutter run
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider
enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.8s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
D/FlutterView( 4752): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@82cc314
Installing build/app/outputs/apk/app.apk... 1.7s
D/FlutterActivity( 5134): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate( 5134): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate( 5134): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate( 5134): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView( 5134): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@eb0c503
D/FlutterActivityAndFragmentDelegate( 5134): Executing Dart entrypoint: main, and sending initial route: /
D/FlutterView( 4752): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@82cc314
D/EGL_emulation( 5134): eglMakeCurrent: 0xa6196880: ver 2 0 (tinfo 0xa48618e0)
Syncing files to device Android SDK built for x86...
I/flutter ( 5134): pressed
Syncing files to device Android SDK built for x86...
I/flutter ( 5134): pressed
Syncing files to device Android SDK built for x86...
I/flutter ( 5134): pressed
Syncing files to device Android SDK built for x86...
(This is taking an unexpectedly long time.) ⣻
flutter run -v
https://gist.github.com/jnnksdev/78c1d2d1b6d86a06d387786c07667918
Visual Studio Code
- Compilations seems fine
- App is not responsive and does not show (white canvas, nothing else)
Run > Start Debugging
Launching lib/main.dart on Android SDK built for x86 in debug mode...
✓ Built build/app/outputs/apk/debug/app-debug.apk.
D/FlutterView( 4752): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@82cc314
D/FlutterActivity( 6179): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate( 6179): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate( 6179): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate( 6179): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView( 6179): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@82cc314
D/FlutterActivityAndFragmentDelegate( 6179): Executing Dart entrypoint: main, and sending initial route: /
D/FlutterView( 4752): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@82cc314
Flutter: Run Flutter Doctor
[flutter] flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.8 at /home/jannik/devenv/flutter
• Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/jannik/devenv/android-sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/jannik/devenv/android-sdk
• ANDROID_SDK_ROOT = /home/jannik/devenv/android-sdk
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_232-solus-ga)
• All Android licenses accepted.
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
uname -a
Linux sol 5.5.7-150.current #1 SMP PREEMPT Wed Mar 4 03:31:00 UTC 2020 x86_64 GNU/Linux
Solution 1:
I did not find out why the syncing process does not finish, but the solution is to switch to a "newer" flutter channel with flutter channel beta
for example.
You can list availale channels with flutter channel
.
Don't forget to flutter upgrade
after changing the channel.
Solution 2:
Put this right before the runApp()
statement in your main function
WidgetsFlutterBinding.ensureInitialized();
This fixed it for me.
Solution 3:
I just found out that using firebaseMessaging plugin can cause this error. if you are using the onBackgroundMessage method, please try to comment it.
I've commented this line and the "syncing files to device" does not get stuck forever...