Flutter taking an unexpectedly long time for connecting to browser - flutter

I'm building flutter web project and after implenting login page via firebase I ran flutter run -d chrome.
But it's stuck while attempting to connect to browser, its just attempting for endless time without giving any error messages. Status bar:
λ flutter run -d chrome
Launching lib\main.dart on Chrome in debug mode...
Building application for the web... 20,2s
Attempting to connect to browser instance..
(This is taking an unexpectedly long time.) \
Flutter doctor:
λ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.10.11-pre.2, on Microsoft Windows [Version 10.0.18362.356], locale ru-RU)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] VS Code (version 1.38.1)
[√] Connected device (2 available)
! Doctor found issues in 2 categories.
pubspec.yaml:
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase: ^5.0.0
firebase_auth:

Try with flutter run -d web-server, then open URL on Chrome manually.

Remove all unused dependencies
flutter run -d web-server
The answer mentioned by #Giampaolo is a great workaround!

Same issue here. When trying the sample project, it works. I think the problem has something to do with dependencies, but have not figured out in detail.
Update:
Could be related: https://github.com/flutter/flutter/issues/40876
and https://github.com/flutter/flutter/issues/39998
Update #2:
I could reproduce the issue a described in
https://github.com/flutter/flutter/issues/39998
1) Create fresh flutter project with web support -> works.
2) add import 'dart:io'; to main.dart -> blank screen

Same issue . It wasn't able to get the instance of browser.
I tried removing unused imports, in my case "import 'dart:ffi';" this was the unused import and ta daa ... it worked !!!.
i just don't know what exactly the problm was.

Same issue: It use to take lot of time to load and 'r', the hot reload command never worked.
For me cleaning builds by "flutter clean" did the magic.

I have fixed that issue by installing the latest JDK and JRE and added both path to environment variables. it fixes my flutter speed but flutter run and apk building still taking the same.

Related

Why it shows parameter not correct on flutter? [duplicate]

I am new to Flutter and today I've been stuck to one problem. I cannot debug my app because it says parameter format not correct
Parameter format not correct -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> Several variant outputs are configured to use the same file name "resources-debug.ap_", filters : MAIN:MAIN
Here's my flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18362.900], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.46.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
I've looked for answers everywhere and they didn't work for my case. Most of the solutions are suggesting to change environment path. This is my path: C:\src\flutter\bin
note: I'm using VSCode
Please help.. thank you!
As I observe your Flutter Doctor, it's already defined that Android toolchain and the Android Studioandroid studio is not configured. So. follow the below steps.
For resolve Android toolchain run the "flutter doctor --android-licenses". And for "Android Studio" resolve please goto Android Studio -> Files -> Settings -> Plugins -> install the Flutter. While installing flutter its also asked for install dart click ok and after installation, it will ask to restart the Android Studio. After restart goes to Flutter terminal and runs Flutter Doctor, Now you have resolved the above issue. The last issue is just ignored because it's just showing that no devices are connected.
And you can run the Flutter in Android Studio in Windows and Mac.
This error occurred because of the app level Gradle.file minSdkVersion property is less than 20 or the targetSdkVersion property is less than 30.
It may work for you. In my case, it works perfectly.
minSdkVersion : 20
targetSdkVersion : 30
run these in your project folder,
flutter channel stable
flutter upgrade --force
flutter pub cache repair
flutter clean
Now try to run

Getting error : "Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead "

Im trying to build flutter web app on release mode using flutter build web(also tried flutter build web --no-sound-null-safety).When i do,im getting the below error.
D:\saves\reset_password>flutter build web
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
.dart_tool/flutter_build/1916f9367c0e6ad6c929bd88cf5227e5/web_plugin_registrant.dart:14:38:
Error: Null safety features are disabled for this library.
void registerPlugins([final Registrar? pluginRegistrar]) {
^
Error: Compilation failed.
Compiling lib\main.dart for the Web... 44.9s
Exception: Failed to compile application for the Web.
It works fine when i run it directly in debug mode using flutter run.
Note: I recently upgraded to flutter 3.0 and im using Android studio.
Below is my flutter doctor( i am aware of the android tools missing.since im building for web,i didnt pay much attention to it)
D:\saves\reset_password>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.1.0-0.0.pre.966, on Microsoft Windows [Version 10.0.19044.1706], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.5)
[√] Android Studio (version 4.1)
[√] VS Code (version 1.66.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
For me was launching flutter clean && flutter pub get on the cmd/terminal, the solution.
flutter build web worked on my local but not on my server, after sudo reboot it worked again. the above sugestet answer didnt work for me...
I had a similar problem.
It was on server based on Ubuntu.
In my case I had:
Target dart2js failed: Exception: Warning:
The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-3.3.19/lib/firebase_auth_web.dart:402:16:
Error: The method 'FirebaseAuthWeb.verifyPhoneNumber' has fewer named arguments than those of overridden method 'FirebaseAuthPlatform.verifyPhoneNumber'.
...
I discovered that a firebase_auth_web dependency had a deprecated version and wasn't used in the project. Hence I removed this dependency. After that the problem disappears.
The fix for this issue is now available on the stable channel 3.3.0. It was due to a change in one of the 3.0 builds that put null safe features in the web plugins registrant. Any web project without null safety would have been affected.
Delete /flutter/bin/cache folder.
Run flutter doctor.
Then, run flutter clean, flutter pub get and flutter build web.
Delete .dart_tool
flutter clean
flutter pub get
flutter build web
I fixed this error by myself.Here's what i did:
I found that there are few dependencies in pubspec.yaml file that are not used currently.I navigated to my .dart_tool\flutter_build\cb8031cdd1bfbcb95122aae4ad9a63d5\web_plugin_registrant.dart and found that those dependencies are being referenced inside registerPlugins().
I cleared all those unused dependencies shown in registerPlugins() and did the following steps:
1.flutter pub get
2.flutter clean
3.flutter build web
And VIOLA! The error went away and i got my files in the build\web folder.

I receive this error while trying to run Flutter app : Could not find an option named "devtools-server-address"

I was developing a Flutter app using the stable channel, in Android Studio, now I upgraded Flutter Plugin to 53 and now when I try to run my app I receive this error
Could not find an option named "devtools-server-address".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
Someone suggested using the dev channel, but I need to continue in the stable channel!
Suggestion Link:
Could not find an option named "devtools-server-address". when trying to run flutter app from AndroidStudio
Just found the fix:
$ flutter upgrade
$ flutter clean
Then select Invalidate Caches / Restart from the Android Studio File menu!
Follow the following steps:
Run the command flutter clean from terminal.
Go to File -> Invalidate Cache and Restart -> Invalidate and Restart.
Now try running your app. The issue should disappear.
If the error still persists: Go to File -> Settings -> Language & frameworks -> Flutter.
Check that the sdk path is appropriate as shown in below image:
Check the Dart sdk path too:
This should solve your problem.
Follow the steps:
File -> Invalidate Cache and Restart.
Run flutter clean
Worked For me.
For a little bit more details, you could also run flutter doctor to see what is happening.
In my case, I've recently updated Android Studio to version 4.2 and when I run the command it gives me:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 1.22.6, on macOS 11.2.2 20D80 darwin-x64, locale en-GI)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2019.3.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Community Edition (version 2020.1.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (1 available)
! Doctor found issues in 3 categories.
As well you could run flutter doctor -v as specified to get more details as verbose (where -v stands for verbose)
In my case the plugins where not visible for Android Studio and wasn't using a stable version of Flutter which didn't allow me to enable the plugins, although they were installed.
After this I've switched to a stable version of Flutter, double checked any required updated from Android Studio, uninstall and re-install the plugins and worked like a charm.
Want to mention that flutter clean and flutter pub get were necesarry afterwards.

Android Studio Dart And Flutter Plugin is not installed

Here is the flutter doctor result:
[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
I have already installed the flutter plugin. But the problem still exists. How can I fix this?
Just run this on your terminal (Mac users)
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Well hello all
I would suggest you all to follow the steps what flutter documentation sites tells you to do
For windows-->There are some people who got detected flutter and dart plugins by the flutter doctor and few are not
I got this issue when I tried to install ...
I did everything like installed flutter and dart plugin still my flutter doctor haven't detected the plugins ...
following steps worked for me
flutter channel dev
flutter upgrade
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
flutter doctor -v
note :--- flutter config --android-studio-dir="C:\Program Files\Android\Android Studio" should be example flutter config "C:\Program Files\Android\Android Studio"
above steps worked for me i hope it will helps you too :)
change channel master to dev.
then upgrade.
flutter channel dev
flutter channel upgrade
try again
flutter doctor
Note: I think it's Android Studio 4.1 issue...
Since you say you have flutter plugin installed in Android Studio, and if Android Studio correctly shows your installed plugin, there is no reason to believe any third-party tool reporting otherwise.
Also, this will not affect your flutter development and your IDE plugins will work as expected inside the IDE and flutter tool's commands work independent of the IDE in use.
Android Studio 4.1 apparently changed its default plugin install path.
Related github issue: [flutter_tools] IDE plugin validators should be deprecated #61246
Flutter does not directly use the IDE plugins, so doctor failing to detect them does not affect any behavior (it's just annoying).
open terminal:
run> flutter channel dev
run> flutter channel updrade
open terminal:
Mac User:
flutter config --android-studio-dir=/Applications/Android\ Studio.app
Reinstall Flutter Plugin from Android Studio
Are you using Android Studio V 4.1?
With Android Studio V4.1 there is a problem.
Try to reinstall Android Studio but Version 4.0.1 and try it again, chances are this will fix your problem.
Open Android studio
Follow the Path Configure > Plugins > marketplace > search Flutter & Dart > Install
Restart IDE(Android studio)
Open Terminal and Export Flutter Path
and run flutter doctor -v
If you are upgrading for an existing project:
Run
git clone https://github.com/flutter/flutter.git
in your terminal.
The be sure to delete the Flutter folder in your App's root directory. Otherwise you will get over 50k errors popping up
Check your flutter PATH
which flutter
if you get /path-to-flutter-sdk/bin//flutter or similar you may have added an extra / in your $HOME/.rc_file. Remove the last '/', restart terminal and try again
this worked for me
flutter channel dev
flutter doctor

Flutter Desktop Linux build failed

When I try to build my app to Flutter Desktop its fail with this message:
Launching lib/main.dart on Linux in debug mode...
Exception: Build process failed
My configuration is:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.19.0-2.0.pre.142, on Linux, locale pt_BR.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)
Can anyone know how to fix this?
Thanks
I had the same issue.
First I ran flutter run -v -d linux, I followed the log and I noticed it an OS Error
Unhandled exception:
FileSystemException: Setting current working directory failed
So, I firstly switch to the master channel (solution for some people), run flutter upgrade and I was getting the same error.
My working dir is /home/xylia/Flutter\ Apps/github_pages and I felt it might be the space from the folder name (I had an issue like that once), so I created a new folder without space and it worked!
I am not totally sure if changing channel to master helped but there is no harm in doing it
I don't know if you already found a solution but for everyone having this problem, I solved it by doing the following:
Inside your project root directory delete the linux folder, like rm -rf linux.
Run flutter clean to delete the build folder and other related files.
Then run flutter create . to make flutter recreate your linux folder.
I had the same problem my fix was to create/run the flutter project on primary SSD/HDD drive.
In my case, it was a dependencies problem. I was trying to use svg_flutter package in a desktop app (which is not supported).
Try running flutter run -v -d linux and check if any error message corresponds with new packages that you added recently.