Flutter in VSCode is not connecting to devtools - flutter

i am using flutter:
Flutter 1.20.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 840c9205b3 (6 months ago) • 2020-08-04 20:55:12 -0700
Engine • revision c8e3b94853
Tools • Dart 2.9.0
the main reason i am still using Flutter 1.20.0 is my own question i asked here also:
is it possible to continue using flutter SDK "1.20.0" and not upgrading anymore? any future problems can arise from that behavior?
till yesterday everything was working well...today i am trying to open devtools in VScode but i keep getting this:
VScode cannot connect
i tried:
flutter pub global deactivate devtools
flutter pub global activate devtools
flutter pub global run devtools
but nothing changes
i tried:
flutter pub cache repair
it reinstalled all my project packages....
and i tried
pub clean it deleted all previous builds
when i try to run App with flutter run --observatory-port=9200
and i take the URL from the logcat and paste it in the devtools to connect to the current working App..i get this:
chrome devtools cannot connect
i am able to run devtools in Android studio successfully with Flutter Inspector...why i am not able to use devtools in VScode!!!

This was a bug in a recent release of DevTools that didn't gracefully handle versions of Flutter that were missing a new API:
https://github.com/flutter/devtools/issues/2648
This bug was fixed in version 0.9.7+2 of DevTools, which VS Code should automatically update to. If it doesn't, you can manually update with:
pub global activate devtools
Note: do not include a flutter prefix.
If pub isn't in your PATH you may need to run it with a full path like:
(flutter SDK)\bin\cache\dart-sdk\bin\pub global activate devtools

Related

How do I fix Dart DevTools Widget Inspector that is stuck showing a circular progress indicator?

I had a Flutter app crash while I was debugging it from the Dart DevTool "Logging" page. After this occurred, all I see when I start debugging is that the Widget Inspector shows a circular progress indicator. I'm now testing with the Flutter default app so it's not something in my code. I've tried restarting my computer a couple of times and the behavior hasn't changed.
An answer to a similar problem (Flutter inspector bugging out/freezing in Visual Studio Code) suggested adding dart.embedDevTools": false, to my VSCode settings.json file. I tried that and still get the same behavior, just in a browser window. Aside: this seems to suggest that the problem is not in VSCode. Finally, I also tried running the app from the command line and launching the DevTools application server directly--same problem.
Any ideas of how I might fix this would be appreciated! If there are none, I guess I will have to try uninstalling and re-installing Flutter and Dart to see if that fixes the problem.
>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19041.1052], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.56.2)
[√] Connected device (2 available)
• No issues found!
>flutter clean
Deleting build... 132ms
Deleting .dart_tool... 4.4s
Deleting .packages... 3ms
Deleting Generated.xcconfig... 4ms
Deleting flutter_export_environment.sh... 2ms
Deleting .flutter-plugins-dependencies... 3ms
Deleting .flutter-plugins... 4ms
>flutter pub get
Running "flutter pub get" in default_app... 1,273ms
>flutter pub global run devtools
>flutter run -d chrome
I finally reached a point where I had time to recover if the reinstall failed so here's what I did to fix this problem:
cd {installdir}\flutter
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
rem • No issues found!
The issue was probably fixed at this point but I went ahead and did the following (except for the two rem steps that I only do when trying to figure out package dependency issues):
cd {projectsdir}\appname
flutter pub upgrade
rem flutter pub outdated
rem flutter pub deps -s list
flutter clean
flutter pub get
cd ..
code appname // Open folder in VScode
<F5>
At this point, DevTools Widget Inspector and Logging are working again!!
Thanks to Suragch who posted the Git steps in an answer to How do you uninstall Flutter completely and properly from a Mac?.
It would be nice to add this info to the Flutter Windows install page but I'm not sure how to even suggest that.
Final Thoughts
There could be issues where this refresh doesn't work. In that case--and in the case where one didn't install flutter as a git repository--I believe that the fix would be:
* delete the flutter directory where you installed flutter,
* remove the paths related to flutter from your environment variable PATH, and
* install Flutter per the install page.
I caution that I haven't tested this approach! If anyone encounters a problem that forces them to resort to this fix, posting an answer here would be appreciated.

Why does the error occur after the Flutter Clean command?

After using the Flutter Clean command, packages cannot be found and too many errors appear.
After running the "flutter pub get" command, the problems are corrected.
It wasn't like this before, what could be the reason for this?
Flutter 2.0.2 • channel stable •
Framework • revision 8962f6dc68 (6 days ago) • 2021-03-11 13:22:20 -0800
Engine • revision 5d8bf811b3
Tools • Dart 2.12.1
Flutter clean removes all cached packages which your IDE depends on for code completion. So that is why after running flutter pub get everything goes back to normal as the command re-downloads all the package files the IDE depends on.
Just run flutter pub get after flutter clean Command.
By doing that dependencies on pubspec.yaml file will be updated as well as flutter and dark SDK dependencies.
Why is it like this, a little confused?

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 run stuck at Installing build\app\outputs\apk\app.apk

Edit: It seemed to work after restarting everything, no other solution really noticed.
I couldn't find useful solutions on following thread:
Flutter stuck at Installing build\app\outputs\apk\app.apk
It's not the same issue, mine doesn't finish installing.
I have an Honor 7 as a connected device and using Visual Studio Code.
When running 'flutter run' following happens:
Launching lib/main.dart on PLK L01 in debug mode...
Initializing gradle... 1,1s
Resolving dependencies... 3,3s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done 15,6s
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk... -
Once last step is loading, my device asks to accept app installation. Once accepted it provides 2 options after installation:
Open App
Finish ( Meaning = return to home screen )
Either way the last step doesn't finish. 'flutter clean' makes no difference. Hot reload not working. Did anyone else encounter this issue ?
'flutter doctor -v' output:
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.590], locale de-DE)
• Flutter version 1.0.0 at F:\flutter
• Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-P, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 2.2)
• Android Studio at E:\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_76-release-b03)
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] IntelliJ IDEA Community Edition (version 2017.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] IntelliJ IDEA Ultimate Edition (version 2017.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2
X Flutter plugin not installed; this adds Flutter specific functionality.
• Dart plugin version 173.4127.31
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[√] VS Code, 32-bit edition (version 1.12.2)
• VS Code at C:\Program Files (x86)\Microsoft VS Code
• Flutter extension version 2.22.3
[√] Connected device (1 available)
• PLK L01 • H8WDU15207300112 • android-arm64 • Android 6.0 (API 23)
! Doctor found issues in 2 categories.
Solutions is quite simple
For flutter hot reload problems that may be happening with your project,
It is a problem with your device, and not flutter or Android Studio
This happens when your logcat hangs up.
You might want to increase your buffer size.
To do this, go into your device or emulator:
Settings > Developer options (Ensure they are turned on),
Change the buffer size to a higher number.
Then run flutter run -v again
Other user may get solution in this url.
In my case the app uninstalled manually so it is not showing in launcher .
and got solution in this
post.
which is
Go to Settings.
Go to Apps.
Select your app. (here, you can verifythat your app is not uninstalled properly).
Open the overflow menu (which are 3 dots)on the top right and select Uninstall for all users.
In my case the problem was that I forgot to change MainActivity.kt package name after I modified it.
package com.WrongCompanyName.WrongProjectName
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
Make sure your MainActivity.java is in the right location, it has a MainActivity class declaration, and that the package matches your package id.
Edit: You can enter this in the terminal
flutter run
And then r to hot reload. You might have to Ctrl+C and n first
It's slower than F5, but still works!
My original answer:
I got around this problem by typing the command in the Terminal
flutter run -d <deviceId>
for my LG phone, it was
flutter run -d LGUS998d7315d51
My solution was to check the package name (iOS is applicationId) of my Android App.
I had recently changed the name of my package from the default "com.example.app_name" to something more custom. However, I had forgotten to change all of the locations.
I believe the most important locations are as follows:
Mac / iOS
build.gradle -- search for "applicationId"
Android
[app_name]\android\app\src\debug\AndroidManifest.xml
[app_name]\android\app\src\main\AndroidManifest.xml
[app_name]\android\app\src\profile\AndroidManifest.xml
Just search for package="
Open android\app\build.gradle and set a different application id to the app.
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.othervalue.sbmicalc"
}
Then remove previous build:
flutter clean
and run again:
flutter run
I have been struggling with this off and on for a year, here is what I just noticed that makes it work or not work on my system.
I discovered tonight that if I have my virus protection running my emulator stalls in the
" ---> Built build\app\outputs\apk\debug\app-debug.apk.
and I just get a white screen. I turn off the virus protection and it works fine in debug mode.
If its on I have to keep going to the terminal and doing: " flutter run " to see any changes I have made.
Maybe this will help someone.
I faced this problem and found a solution.(I use emulator)
It seems this is just an emulator problem.
AVD Manager -> Actions -> Wipe Data
Maybe you need to do flutter clean, but the problem will solve.
In my case, it was not uninstalled the flutter app properly from mobile phone because my mobile has normal space and private space...so when I uninstall the app from normal space it was uninstalled but not uninstall from private space. then after removing the app from private space and run
flutter clean
and run the again it's work fine!
flutter run
I have also faced the same issue when I have changed targetSdkVersion to static values (33) in my case
android/app/build.gradle
targetSdkVersion flutter.targetSdkVersion to targetSdkVersion 33
So, By un-doing changes and by adding constant in local.properties worked for me
android/app/build.gradle
targetSdkVersion flutter.targetSdkVersion
and
android/local.properties
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.targetSdkVersion=33
If you see your app installed like this -> just click it to open. It worked for me