Flutter run command not working

2019-04-01 17:57发布

问题:

Can anyone tell me why my app is not installing at all and ending with the error message

Observatory connection never became ready.

the app was working perfectly fine until yesterday .

I have changed the channel to master yesterday in the command prompt and from then on the app never runs.

I even switched back to channel alpha but still no use.

I have attached a screenshot of the command prompt where the installation was stuck forever.

I am not so sure if I need to reinstall the flutter. I am worried if I uninstall the flutter now it may not configure properly and I might break it forever.

Please can someone tell me what exactly might have gone wrong.

Many Thanks, Mahi

Screenshot of command prompt

回答1:

Instead of reinstall try with following: (Mac)

  • Set Path Variable: via following terminal command

    export PATH=~/flutter/bin:$PATH;

that is bin folder path of flutter.

   export PATH=[PATH_TO_FLUTTER_GIT_FOLDER]/bin:$PATH

https://flutter.io/setup-macos/#update-your-path

  • If above not worked. Check with the Dart version

    dart --version

Install the latest dart version:

    brew install dart --devel

Hope this helps others.



回答2:

The solution is from Google Groups @Flutter-Dev

Thank you very much for your reply @Michael Thomsen.

I've tried what you have suggested and the details are as follows:

  1. When I used flutter run -v command the command prompt output is as follows: It was stuck for a while at waiting for port connection if I am not wrong.

So I've used AndroidStudio, File>Open and selected android/ folder to run the app then the gradle was showing an error:

Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.2.0) and test app (25.4.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

I modified the build.gradle(Module:app) to show the correct version of 25.2.0 which was previously showing 25.4.0.

 dependencies {
  androidTestCompile 'com.android.support:support-annotations:25.2.0'
  }

I just saved the changes inside android studio and the gradle sync completed without any errors.

Now I can run the app from inside Android Studio and also from IntelliJ IDE.

Thanks very much Michael this solved my problem.



回答3:

Reinstalling flutter would be my starting point. If this problem persists, please post the output of $>flutter doctor and a description of what exactly leads to this error.



回答4:

For Mac open terminal

  1. $ echo $PATH it will show like this /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: it means you need to add flutter in to path

  2. Open Finder presss command + shift + G

    Put /etc/paths in dialog and press GO

    Copy the file "paths" and paste it on desktop

  3. Then open the pasted "paths" file from desktop and add following line into end of the file "/flutter/bin"

  4. Then copy that file and again paste it on /etc/paths same like step no 2

  5. it will ask you to replace or not

    press replace

Now if you hit $ echo $PATH on terminal it will show /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/swagat/development/flutter/bin

Now your $flutter doctor will work perfectly



标签: dart flutter