Flutter run waiting for connection from debug service on chrome - flutter

I use flutter on window 10, when i run flutter on console and perform flutter run -d chrome, the error is waiting for connection from debug service on chrome. The error from chrome page show "The connection cant be reach".
My flutter doctor show i didnt install Visual Studio, but i already used to the Visual Studio Code. Is it a must to install Visual Studio ? Other than that, everything is passed.
I try to run the app on Visual Studio Code, the error is the same. Even on edge, on web-server. The error is the same.
I try to add Dart Debug Extension on Chrome but cannot be enable. Can some help ?
My flutter run -d chrome --verbose show below :
[tag:C:\Users\Administrator\myflutter_app>flutter run -d chrome --verbose
[ +10 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+19685 ms] Waiting for connection from debug service on Chrome... (completed in 20.0s)
[ +2 ms] Synced 30.6MB.
[ +1 ms] <- accept
[ ] Caching compiled dill
[+2477 ms] [CHROME]:
[ +18 ms] [CHROME]: DevTools listening on ws://127.0.0.1:57469/devtools/browser/51db6ac9-54b7-4fb7-bdb4- 25fb1707d9d6]

The problem can be solved by performing the following actions
Upgraded flutter to latest version
Reinstall android studio
run flutter pub upgrade --major-versions
upgrade your chrome to latest
if you are using any extension in VS code to run flutter then there is also a possibility that the extension is not working properly try to change the version.
If it works give me a upvote,I'm new here.

Related

Launch emulator from windows command line receive error G67247B7E

Newbee here. Trying to run the android emulator for the generic first_app flutter application.
Run flutter run -d windows
Receive:
C:\Development\Flutter\first_app>flutter run -d windows
Launching lib\main.dart on Windows in debug mode...
lib/main.dart(60,15): error G67247B7E: Expected ';' after this. [C:\Development\Flutter\first_app\build\windows\flutter\flutter_assemble.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\Development\Flutter\first_app\build\windows\CMakeFiles\13756e3632117b79f6e0bc292bc438e0\flutter_windows.dll.rule;C:\Development\Flutter\first_app\build\windows\CMakeFiles\f154f6c681490929a1ff6491e40cd6b3\flutter_assemble.rule' exited with code 1. [C:\Development\Flutter\first_app\build\windows\flutter\flutter_assemble.vcxproj]
Building Windows application...
Exception: Build process failed.
Other information:
Flutter Doctor is clean. That took hours.
Running from Android Studio works.
Launching emulator works correctly
Have tried Flutter Clean, Flutter upgrade, Flutter Master.
Have tried running from powershell with the same error.
Any assistance welcomed.
First you can check if the emulator is running or not by this command
flutter devices
Then you can directly run your app through
flutter run -d device-id
In my case, it was
flutter run -d emulator-5554
All, on a whim, I deleted my first_app and created it again via flutter create first_app.
Immediately running flutter run, it works!

Only Flutter web relese build does not work

When I run the Flutter web app in Android Studio using the run button or by flutter run -d Chrome, everything works just fine.
When I run flutter build web and open $(project_dir)/build/web/index.html, I get a white screen. There are these errors in the browser console:
Failed to load app from a service worker. Falling back to plain <script> tag. index.html:85:21
Loading failed for the <script> with source “file:///main.dart.js”. index.html:1:1
When I run flutter build web -v there is following:
[ +68 ms] Skipping target: web_entrypoint
[ +1 ms] Skipping target: gen_localizations
[ +311 ms] Skipping target: dart2js
[ +10 ms] invalidated build due to missing files:
/home/vanousek/prg/substance-mix/DOES_NOT_EXIST_RERUN_FOR_WILDCARD954977783
[ +72 ms] web_release_bundle: Starting due to {InvalidatedReasonKind.inputMissing: The following inputs were
missing: /home/vanousek/prg/substance-mix/DOES_NOT_EXIST_RERUN_FOR_WILDCARD954977783,
InvalidatedReasonKind.inputChanged: The following inputs have updated contents:
/home/vanousek/prg/substance-mix/build/web/main.dart.js,build/web/index.html}
[ +121 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for
more information see #56466.
When building your flutter app for web it's intended to be run on a web server.
Running flutter build web, would compile the project into a web project. You can use web hosting providers such as netify, firebase hosting, and Github pages.
Running the ./build/web/index.html would not show up. That's why you got the errors in the console.
You could run flutter run --release -d chrome to run on Chrome in release mode.
EDIT:
This is chrome DevTools, it seems that the site was looking for the main.dart.js and other resources.
I noticed it was pointing towards https://your_url/main.dart.js but the resource is located in https://your_url/substance_mix/main.dart.js. So it threw 404's.
One solution to this is to edit the index.html and add /substance-mix/ to all resources. Eg. change scriptTag.src = 'main.dart.js'; to scriptTag.src = 'substance_mix/main.dart.js';
or you can the GitHub Pages configurations. And have your website directly on https://mikulasvanousek.github.io/

Flutter app crashes on hot restart only on iOS Simulator

Not sure what is going on, but when I hot restart my flutter app crashes using iOS simulator. Hot restart works fine on an Android simulator. I even tried to uninstall and install XCode again.
Here is what gets printed on the terminal
[ +459 ms] Hot restart performed in 924ms.
[ +3 ms] Restarted application in 936ms.
[ +900 ms] Service protocol connection closed.
[ ] Lost connection to device.
[ +3 ms] DevFS: Deleting filesystem on the device (file:///Users/frederickmfinanga/Library/Developer/CoreSimulator/Devices/775342AF-E52F-46EB-9CDB-9C29720FC357/data/Containers/Data/Application/D093EF45-D895-481C-B965-CA56F7881A5C/tmp/the_hair_routinenSBAWo/the_hair_routine/)
Failed to send request: {"jsonrpc":"2.0","id":"46","method":"getMemoryUsage","params":{"isolateId":"isolates/4165970133496907"}}
[ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[ +1 ms] "flutter run" took 646,839ms.
[ +259 ms] ensureAnalyticsSent: 242ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ ] Shutdown hooks complete
[ ] exiting with code 0
I had the same issue. After two days of debugging I have just found out it was caused by one of my dependencies. It is firebase_auth package version 1.1.3.
As I can see the issue is resolved in firebase_auth 1.1.4 released on 10th of May 2021.
So just update to firebase_auth 1.1.4 if you use this package
I faced something similar a few days back.
There can be two possibilities why it is happening :
You have not granted permission for something you are trying to access (like getting the location/camera ). If this is the case then read the docs of the package you might be using and add the permissions programatically.
Sometimes our podfile reference gets corrupted. (This is what happened in my case). For this delete your podfile.lock file (ios/podfile.lock). For a fresh start you can also delete your pubspec.lock as well. And then do a flutter pub get or simply run your app.

Failed to establish connection with the application instance in Chrome

Failed to establish connection with the application instance in Chrome. This can happen if the websocket connection used by the web tooling is unable to correctly establish a connection, , for example due to a firewallfor example due to a firewall.
i am getting this error whenever i run flutter web application on chrome in debug mode. i disable firewall and still not working, but when i run it in release mode its work. can anyone help me please! i am using window 8.1 64bit
What seems to solve the issue is running the following commands inside your flutter project directory:
flutter clean
flutter run -d chrome --release
After running the first time in the release mode, you can then run in the debug mode with just:
flutter run -d chrome
Reference:
https://github.com/flutter/flutter/issues/49482
this worked for me ( no firewall issue, no Dart Debug Extension installed )
➜ somefolder flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 125.9s
Failed to establish connection with the application instance in Chrome.
This can happen if the websocket connection used by the web tooling is unable to correctly establish a connection, for
example due to a firewall.
➜ somefolder flutter clean
Cleaning Xcode workspace... 39.2s
Deleting build... 712ms
Deleting .dart_tool... 97ms
Deleting .packages... 0ms
Deleting Generated.xcconfig... 16ms
Deleting flutter_export_environment.sh... 0ms
➜ somefolder flutter devices
1 connected device:
Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.128
➜ somefolder flutter run -d chrome --release
Running "flutter pub get" in somefolder... 10.8s
Launching lib/main.dart on Chrome in release mode...
Compiling lib/main.dart for the Web... 38.3s
🔥 To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
Performing hot restart... 5.5s
Restarted application in 5,489ms.
Performing hot restart... 394ms
Restarted application in 394ms.
Performing hot restart... 375ms
Restarted application in 375ms.
Application finished.
➜ somefolder flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 37.9s
Debug service listening on ws://127.0.0.1:64242/GMDUxFrKo2U=/ws
Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
🔥 To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
You need not to disable firewall,
You have to download Dart Debug Extension on Google Chrome then run
flutter app on web

Issue with Flutter commands after Flutter upgrade

My project was working okay before I got Flutter upgrade prompt. After accepting to upgrade flutter, I started getting the following exception and now with every flutter command I get this exception. Also since that problem started Android Studio does not pick up any running emulator. So basically, I'm stuck, please help. It just displays "Loading..." instead of displaying the running Emulator.
Version Information:
Android Studio 3.4.2 • Flutter plugin io.flutter 38.2.1 • Dart plugin 183.6270
I've change the permission for git.EXE to allow for read, execute etc but this has not helped.
ERROR MESSAGE:
CreateProcessW failed 5
Unhandled exception:
ProcessException: Access is denied.
I have faced the same issue after running the flutter upgrade command
Remove exiting flutter SDK from the directory "https://flutter.dev/docs/get-started/install" and download again and run the following command
flutter doctor -v
After running the flutter upgrade command in the Windows CMD I faced the same issue.
I then tried to upgrade Flutter SDK using the Android Studio terminal and it upgraded successfully.