Naveen Cherian
Naveen Cherian

Reputation: 49

Unable to run new flutter sample code in IntelliJ IDEA

I installed IntelliJ IDEA, downloaded both the flutter and dart plugins, Installed android studio and jdk . I opened configured IntelliJ IDEA to point at the android sdk and jdk.
I opened up IntelliJ IDEA and created new project->flutter. I clicked on build and got an error message.

I am using Ubuntu 16.04 64 bit system

I ran Flutter Doctor and confirmed that i got nothing new or missing installation. The message at debugger is as shown

The built-in library 'dart:ui' is not available on the stand-alone VM. 
library handler failed export 'dart:ui' show Locale
Process finished with exit code 254 Failed to connect to the VM observatory service: java.io.IOException: Failed to connect: ws://127.0.0.1:46579/ws Caused by: de.roderick.weberknecht.WebSocketException: error while creating socket to ws://127.0.0.1:46579/ws Caused by: java.net.ConnectException: Connection refused

Standard new flutter project code with output

Debugger output which i copy pasted

Upvotes: 2

Views: 3432

Answers (6)

collins omwoyo
collins omwoyo

Reputation: 11

I ran into this issue on VS Code and the solution is: If you are using VS Code then instead of hitting Run (Ctrl+Alt+N) go to Debug -> Start Debugging option or simply press F5 and errors will be gone

Upvotes: 1

M.mhr
M.mhr

Reputation: 1759

I had same issue on Android Studio and I find out that its related to the file (configuration) selected here:

enter image description here

The first one is Dart Command Line App and the second one is Flutter App which should be selected

Upvotes: 1

Raj008
Raj008

Reputation: 3927

Your setup looks good! I think IntelliJ is trying to run your app as if it was a command-line dart app, not a Flutter one. There are some settings in IntelliJ to allow you to manage your launch configs. I would: delete the dart command-line one create a flutter one for your app (or confirm that one exists) Then, from the launch config drop-down, select the flutter launch config for your app and hit run.

There are some docs here: https://flutter.io/intellij-ide/#running-and-debugging, though they don't cover creating a launch config.

Referenter link description here

Upvotes: 0

Kathryn Newbould
Kathryn Newbould

Reputation: 63

Click the name of the test, and choose "Edit configurations" You'll (probably) notice that the run config is under 'dart' rather than 'flutter test'

Delete this one, create a new one (using the plus button) under 'Flutter Test' and choose / run this manually.

(Also, you need to have the tests in a folder called 'test' at the same level (e.g. as a sister to) the lib folder, and follow the naming convention '*_test.dart' for all tests.)

Happy coding!

Upvotes: 6

lordvcs
lordvcs

Reputation: 2952

When i encountered this issue, I fixed the error by simply by closing the current project and creating a new project. Now when i tried to run the app from the new project, it worked!. Hope it helps someone.

Upvotes: 0

Collin Jackson
Collin Jackson

Reputation: 116828

It sounds like IntelliJ is configured to run as a Dart command line app instead of a Flutter app. Edit configurations and remove any configurations that look like "Dart Command Line App". Then create a new one for a Flutter app.

Upvotes: 8

Related Questions