8

So I created a Flutter project in IntelliJ Idea Community Edition on machine A and then uploaded the whole project on GitHub. Now I cloned/checked out from GitHub in the same IDE on machine B, performed the following:

  • flutter packages get
  • flutter upgrade
  • Set up the dart path and all other prerequisites

But, I am still unable to run the flutter project from IDE. I mean I can't even press the "Run" button.

Unable to press the run button

Where did I go wrong?

You can try performing the same steps as I did. it if you want. Here's the Git repository code

Edit I can run the same project via terminal.

[Update] As requested by Günter Zöchbauer in the comment log, here's the logs for flutter doctor -v

BoringFlutterProject$ flutter doctor -v
[✓] Flutter (Channel dev, v0.5.8, on Linux, locale en_IN)
    • Flutter version 0.5.8 at /home/daksh/flutter
    • Framework revision e4b989bf3d (8 days ago), 2018-08-09 09:45:44 -0700
    • Engine revision 3777931801
    • Dart version 2.0.0-dev.69.5.flutter-eab492385c

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /home/daksh/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME = /home/daksh/Android/Sdk
    • Java binary at: /home/daksh/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.1)
    • Android Studio at /home/daksh/android-studio
    • Flutter plugin version 25.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Community Edition (version 2018.1)
    • IntelliJ at /home/daksh/Downloads/idea-IC-181.5281.24
    • Flutter plugin version 25.0.2
    • Dart plugin version 181.4892.1

[✓] VS Code (version 1.26.0)
    • VS Code at /usr/share/code
    • Flutter extension version 2.17.1

[!] Connected devices
    ! No devices available

! Doctor found issues in 1 category.

I posted this question because I'm sure many of us will face the same problem, just like we used to face some issues in AndroidStudio back then

Daksh Gargas
  • 3,498
  • 2
  • 23
  • 37
  • Did you install the Dart and Flutter plugins in IntelliJ? Try opening the `pubspec.yaml` file in IntelliJ and confirm if it asks you to add Dart support to your project. Also try `flutter run` in a terminal window. – Günter Zöchbauer Aug 17 '18 at 11:29
  • indubitably "Yes", if I try to "create a new Flutter/Dart project" it works. It's just not working if I checkout from Git. I have provided a link to my code, you can test it if you want. I simply uploaded my whole folder – Daksh Gargas Aug 17 '18 at 11:37
  • Did you try `flutter run` in a terminal window? Please also add the output of `flutter doctor -v` to your question. – Günter Zöchbauer Aug 17 '18 at 11:40
  • yeah, I guess I did mention that the code works outside the IDE. Wait, I didn't, let me update my question. It's just some IDE error, that's it. – Daksh Gargas Aug 17 '18 at 11:51
  • are both machines runnning the same flutter version (run `flutter doctor` in both)? if you run `flutter upgrade` in the first machine, does the project still work there? are both machines in the same `flutter channel` ? – Feu Aug 17 '18 at 15:07
  • Yep, everything is same, perhaps it doesn't really matter. And as I said, I can run it via terminal. :/ – Daksh Gargas Aug 17 '18 at 15:08
  • I am facing the same issue, pls help. – Ajay Sep 04 '18 at 11:46
  • Facing similar issue, works well on my VSCode but fails on intelliJ – Jitendra Singh Sep 07 '18 at 11:56
  • Both IntelliJ and Android Studio sucks when trying to import/open a flutter project checked out from Git. That's some tremendous crap, I can create new flutter proejcts but canot open some that other people were working on in VS Code. – Alexander Arendar Dec 11 '18 at 15:50
  • Welcome to the club!! :D – Daksh Gargas Dec 11 '18 at 15:51
  • [enter link description here](https://stackoverflow.com/a/60296518) This is Answer solved my problem although i am using intelliJ IDEA – MO_amer Jan 02 '21 at 10:57

6 Answers6

7

It is an Android Studio issue. The IDE doesn't apply the flutter SDK location for every new project you clone. The workaround is to open the cloned project go to File>Settings(Ctrl+Alt+S). In 'Languages & Frameworks'>Flutter set the SDK path to your Flutter SDK location (e.g. C:\src\flutter). Once you apply the changes and run the 'Packages Get' command the cloned project is fully accessible and understood by Android Studio.

Marc Steffens
  • 92
  • 1
  • 6
  • It is what I do every time. As I recently started programming in flutter, I regularly clone open source projects for referential bases. Every time I have to apply the workaround to fix the project and remove all errors flagged by Android studio – Marc Steffens Feb 19 '20 at 09:20
  • Alright @Marc I'll use your answer then :) Thanks! If you want, please provide step-by-step information so other users can easily use your solution. Feel free to attach screenshots too. Thanks! – Daksh Gargas Feb 19 '20 at 09:22
2

I've succeeded to run you project. When I've first open it showed me that it can't find the location for Dart SDK, once I've set the location of the flutter sdk as explained here:

Dart SDK is not configured

it automatically update the location of the Dart SDK, then I've had to run get dependencies, then it run.

Moti Bartov
  • 3,454
  • 33
  • 42
1

If you have flutter and Dart plugin installed.

Now the problem is Dart support for this project is disabled now you have to enable it.

Step 1: Go to Settings -> Languages & Frameworks -> Dart

Step 2: Check the "Enable dart support for this project"

Step 3: Set the Dart SDK path to your Dart SDK folder like the picture given bellow

enter image description here

Step 4: Click on Apply

That's all!

Saiful Islam
  • 1,151
  • 13
  • 22
0

Too late but pubspec.yaml-> Pub outdated( on top left of Android Studio's screen) -> build on real device solved my problem

0

In addition to answer by @Marc Steffens above, to run on Chrome and not an emulator or device, I also had to run "flutter create ." from the project root in the terminal. Note the trailing ".".

mLstudent33
  • 1,033
  • 3
  • 14
  • 32
0

What helped in my case, was simply removing the .idea folder in the project root.

speedi33
  • 136
  • 1
  • 7