Flutter users should run `flutter packages get` instead of `pub get` - android-studio

I got a flutter project to complete from my friend.
I am using Android Studio(AS) as editor. I have installed flutter and dart plugins in AS. Now, I have imported the flutter project by selecting option at start of AS import AS project. Then it I don't know why it shown me error message to setup Dart SDK(Q1: my first question is why it is giving error I already have dart plugin). Somehow I managed to get Dart from this link and gave path to till dart-sdk folder as seen in screenshot
And now I am stuck on this error:
Because xxo_tag_xxxls depends on flutter_test any from sdk which doesn't exist (the Flutter SDK is not available), version solving failed.
Flutter users should run flutter packages get instead of pub get.

you should configure in addition to the Dart language SDK, pointing to the Flutter SDK ('C:\src\flutter') within your Andoid Studio project. Go to the top menu 'Tools > Flutter > Flutter Clean' and the IDE will ask you to configure what is missing.

in mac if you are using android studio, go to android studio at the top left, preferences, flutter, then add path to sdk

you have to configure in addition to the Dart language SDK, pointing to the Flutter SDK ('C:\src\flutter') within your Andoid Studio project. Go to the top menu 'Tools > Flutter >flutter package get and click on it ,it will find the things those are missing.

Related

Dart SDK is not configured in Android Studio

I just started learning the Dart programming language, then I did some preparations such as installing the Dart SDK, then setting the path for the bin, after that I checked using the command prompt and it didn't cause any problems. After that I started to code Dart program, and Android Studio gave message "Dart SDK is not configured" , then I clicked "open Dart Setting" and set SDK path, then applied it. But still Android Studio gives message Dart SDK is not configured.
Please help to solve this problem
Under Settings, go to Languages & Frameworks, choose the language you are using and check if the field SDK Path has the correct address. For example, mine is flutter so I have added the correct path as shown in the image. Dart SDK not configured

Flutter UI Guides not showing in Android Studio

In Android Studio V4.1.3 (build no. Al-201.8743.12.41.7199119) The Flutter UI guides for widgets and methods not showing at all even though it is enabled in the settings. Please, be kind to see the screenshot =>
no Flutter UI guides
I have Flutter Plugin V55.1.1 and Dart Plugin V201.9335 installed.
All your help is highly appreciated.
Thank you
You might be creating the new Flutter project and selecting Java for Android. But when you select Kotlin and create project. The issue will be fixed.
And if you want your old projects to be converted to Kotlin, just open the terminal in that project and run this
run flutter create -a kotlin .
The dot(.) at the end is also important it will generate the Kotlin files in current directory.
After this, just re-open the project, you'll get the guides.
I have the same android studio version as you and Flutter Plugin V55.1.1 and Dart Plugin V201.9380 installed. Getting the same issue. I have even tried to enable and disable the "Show UI guidelines for build methods" in Setting > Language & Frameworks > Flutter, but nothings work.
I cloned flutter/sample from GitHub and it seem that the UI guides is showing on that samples project.
My current (kinda easy cheat) solution right now is by creating a New Flutter application project via VS Code. And when I open that flutter project on Android studio, the UI guides is there. I have configure my VS Code with the recommended setting for Dart code.
Tutorial to configure your VS Code reference: https://youtu.be/nAmOt5_fMtU?t=278
I'm pretty new in flutter development but I'm pretty sure there might be something that we can configure on Android Studio seeing that generated project file from VS Code does shows the UI guideline. If someone know how do let me know. Cheers!

Flutter project import Android studio

So im new to flutter and wanted to check out an example project to see how its set up architecure wise. For this i stumbled upon InKino. Looks like a nice app to check out as example.
https://github.com/roughike/inKino
When i open Android Studio > file > Open... and select the folder that i have cloned previously it somehow does not detect that its a flutter project. And cant seem to run it
However when creating a new flutter project everything is working fine and i can run my project as per usual.
I have installed latest flutter and dart plugins for Android Studio. Also the flutter SDK and Dart sdk are installed.
I downloaded the repository you linked and my Android Studio identified the project as flutter project. What I did is opening the mobile sub folder not the whole repository folder, because the repository contains multiple different type of projects.

How to set the project type to Flutter in Android Studio

I'm having a problem understanding how to configure a Flutter project in Android Studio. I've done all the Flutter/Dart install steps and I can successfully build Flutter projects. My problem is setting the project so the Project View window in Android Studio sees my projects as Flutter projects and not an Android project. For example, here's a screenshot of a Flutter project I created:
Android Studio Project View Java folder
Notice the Java "coffee cup" on the flutter_app folder and the "[flutter_app_android]" on the android folder. Here's an example of a Flutter project that seems to correctly be identified as a Flutter project in Android Studio:
Android Studio Project View Flutter folder
I've tried creating new Flutter projects in Android Studio and by the flutter create command line. This is driving me nuts and is probably something trivial but I can't find the setting that makes my project recognized as a Flutter project.
Actually I typically use the project view as you have shown in your first image. The Flutter code is in the lib folder. Being able to see the 'android' and 'ios' folders can be helpful if you need to configure something specific like Firebase Cloud Messaging or you need to add channels to your Flutter app to call native iOS or Android code.

How to open an existing Flutter Project in Android Studio

I might sound noob here but I can't see a clear way of opening existing Flutter Project in Android Studio 3.1.2.
I checked this but it didn't work. So I want to know if there is a standard IDE way of doing this? I also can't find any docs clearly mentioning it. Do I need to install a 3rd party plugin?
After opening it as an Existing Android Studio Project, I get the following error:
The error is solved by running Get Dependencies. Is it a normal behavior?
Install Flutter plugin for Android studio: https://flutter.io/get-started/editor/
Open Android Studio
Open existing Android Studio project by using one of below methods:
EASIEST WAY: Drag your project folder and drop to Android Studio.
Other ways:
What works for me was to open existing Android Studio project like mentioned above, and then go to menu
Tools -> Flutter -> Flutter Clean
Then configuration window will open and ask you to locate flutter sdk. After locating the sdk, click OK and then the flutter functions will be available (Pub buttons, runs menu). After that you can proceed to get the dependencies (pub get).
It's basically cleaning the project folder of previous setting(s) which might conflicting with the system (android studio). But that won't happen if you get the project from source repository because all of the junk files wont be in the project folder.
The quickest way on macOS is
open -a Android\ Studio android when you are in the root project directory.
Alternatively, if you use the jetbrains toolbox, you can enable "Shell Scripts" in its settings. This will create a binary in the folder of your choice, so you have to add this folder to your PATH. Then, you can use studio . inside the Android folder, or studio android in the flutter project. The benefit of this, is it also works with other Jetbrains products (e.g. charm project_dir or clion project_dir. Unfortunately this method glitches out (for pycharm at least).
Looks like Android Studio can't load Android Application module from Flutter project automatically. I also have same problem, so in my situation Gradle can't be found, because of lack of Android project.
There's important note from official site:
Important: Do not use the New > Project from existing sources option for Flutter projects
I suggest, same is for Open option.
Just Open your project as normal, and then in [Android Studio > Preferences > Languages&Frameworks > Flutter > Flutter SDK path] select the path where you downloaded & unpacked Flutter SDK.
I know it's already late, but you can open an existing Flutter project in Android Studio by following these steps (make sure you have already installed Flutter & Dart plugin and Flutter SDK):
Click Open from File menu in Android Studio,
Go to the path of the project,
Click Open from the dialog,
When the project opens in Android studio, it will show an error of packages and dependencies. So, click on Get Dependencies on the top. Android Studio will automatically add all the required dependencies and packages.
There is a simple way of doing this in android:
Just Open your project as normal, and on the top right corner, click on Flutter Attach option, and voila!
See Attached screen grab!
Usually you can open your Flutter project in Android Studio simply when you right click on the android folder > Flutter > Open Android module in Android Studio but sometimes this option could be disabled, check this answer to enable..

Resources