Unable to run flutter project - android-studio

I've installed flutter SDK and started a new sample project , but couldn't run it ,here is the logCat
I tried running it on both android studio and VsCode and got the exact same log message.
When I tied running flutter doctor command in terminal I got this error:-
I think the issue is in the Dart-SDK but I've downloaded it from the flutter page as well as from Dart documentation.
Here are my environment variables in path
C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\git-cmd.exe;C:\Windows\System32;C:\flutter\flutter\bin

Try putting flutter in C:\src (full path should be : C:\src\flutter\ )
You should also update your env variables in path to : C:\src\flutter\bin, do that also for Dart sdk, env variable should be : C:\src\flutter\bin\cache\dart-sdk\bin
After That go to command line and type flutter doctor.

Related

I try to make android studio (emulator) work with vs-code but have an error "avdmanager is missing from the Android SDK"

This is my PATH
export ANDROID_SDK_ROOT=/mnt/sda1/DevTools/sdk/
export ANDROID_HOME=$ANDROID_SDK_ROOT
export PATH=${PATH}:/mnt/sda1/DevTools/sdk/platform-tools
I try many cases, but still this error!
Try :
flutter doctor --android-licenses
if something wrong, try to locate android sdk path.
flutter config --android-sdk {path}
Mine :
flutter config --android-sdk C:\Android\Sdk
This worked for me. If you have sdkmanager, avdmanager and emulator, and you have them in your PATH environmental variable, then
Download a system image:
sdkmanager "system-images;android-30;google_apis_playstore;x86_64"
(you can find available packages with sdkmanager --list --verbose)
Create a new virtual device with
avdmanager create avd --name MyAndroidDevice --package "system-images;android-30;google_apis_playstore;x86_64"
Start the emulator
emulator -avd MyAndroidDevice
Now restart VSCode and open your Flutter project. The new device should be at the bottom right corner or you should be able to choose it by clicking on "No device".
For me, I had to restart my VS Code for the installation of Android SDK be reflected upon it.
I know this is an old question but setting my $PATH variable in ~/.bashrc (I'm on Ubuntu 20.04) did not work for me.
I needed to setup Android Emulator for VScode, because I wanted to run my flutter app, which seems to be the same issue as OP had.
Instead of setting the $PATH directly you can actually use Flutter in the terminal to do it.
If you run "flutter config" in the terminal you get something like:
Configure Flutter settings.
To remove a setting, configure it to an empty string.
The Flutter tool anonymously reports feature usage statistics and basic crash reports to help
improve Flutter tools over time. See Google's privacy policy:
https://www.google.com/intl/en/policies/privacy/
....
Run "flutter help" to see global options.
Settings:
android-sdk: <my_path_to_android_tools>
Analytics reporting is currently enabled.
You can then see the $PATH that is currently set with flutter under:
Settings:
android-sdk: <my_path_to_android_tools>
Mine was incorrect so I changed it to the current one with the command:
flutter config --android-sdk <my_path_to_android_tools>
Afterwards I restarted VScode and when it was finished loading I could now press the "device" button in the right hand corner and then select emulator that I had already created. I used one of the above answers to install the emulator itself.
It took a while to launch the emulator the first time due to installing some dependencies but it did work!
I tried this and works:
from terminal run flutter config --enable-android. You will get Setting "enable-android" value to "true".
after that open android studio, set up virtual devices first if you haven't. Open Android Studio -> Configure -> AVD Manager -> Create Your Virtual Device
Go back to your VS Code, open command Palette (Ctrl+P or cmd+P, then type >), or from View -> Command palette... -> Flutter: Select Device -> choose your android device
I faced the same issue and solved it running flutter doctor from the terminal, in VS Code. In my case, I had the android sdk located in a custom location (D drive), the reason why it wasn't found automatically. The "doctor" told me to run flutter config --android-sdk <my-sdk-custom-location>. Running it and restarting the IDE made the trick. Hopefully this helps someone facing the same problem.

Flutter create command was unsuccessful

I'm creating a new flutter project in Android studio for the first time. I give the project a name and choose Flutter sdk. I then clicked finish and then noting happened. Android studio says that
"Flutter create command was unsuccessful"
When I navigate to command directory using file explorer, I new folder is created with the project name I've given but it is empty.
Please help.
I don't think you installed flutter correctly. First and foremost, make sure you run flutter doctor from your terminal.
If it doesn't work then you didn't install flutter properly.
If it works, try creating your project via terminal by typing flutter create projectname
I hade the same issue in ubuntu
first, check flutter doctor and solve the error if there was
then check the git installation
in my case, I didn't install git
On Windows at least you need to add <flutter_dir>\bin to your path, and then restart Android Studio. It is not clear to me why Android Studio needs to know the location of the Flutter SDK if it doesn't then use that information but... :shrug:
Git also needs to be in the PATH too (as C:\Program Files\Git\cmd); I have always used git-bash just fine without that but now it seems to be a requirement that isn't clearly surfaced when upgrading.
In My case set the flutter sdk path first while create the app and then create the app

Error setting up flutter for the first time

I am having an issue getting flutter doctor to set up or create flutter projects in Android studio. I get the following error when I try to run flutter doctor.
ProcessException: ProcessException: The system cannot find the file
specified.
Command:
C:\Users\Joshua\AppData\Local\Android\Sdk\tools\bin\sdkmanager.BAT --licenses
I already did the steps in this link:
How to accept licenses with flutter doctor?

Flutter create command was unsuccessful error

I'm creating a new flutter project in Android studio. I give the project a name and choose Flutter application. I then clicked finish and then nothing happened.
Android studio says that
"Flutter create command was unsuccessful"
When I navigate to command directory using file explorer, a new folder is created with the project name I've given but it is empty.
Please help.
A simple Android Studio restart did the trick for me
I've solution to this problem now.
After running flutter doctor --android-licenses I got to know that I need to update my sdkManager.
Then I went to that directory using
cd C:\Users\[user-name]\AppData\Local\Android\Sdk\tools\bin
and run sdkmanager --update
Then I restarted the Android Studio and tried creating flutter project.
It worked.
check your FLUTTER SDK path of the project (android studio: file -> settings -> Language & framework -> flutter -> flutter sdk path) . Or execute flutter doctor command in flutter consol.(This worked for me)
please install all the dependencies that flutter wants
Operating Systems: Linux (64-bit)
Disk Space: 600 MB (does not include disk space for IDE/tools).
Tools: Flutter depends on these command-line tools being available in your environment.
*bash
*curl
*file
*git 2.x
*mkdir
*rm
*unzip
*which
*xz-utils
*zip
Shared libraries: Flutter *test command depends on this library being available in your environment.
libGLU.so.1 - provided by mesa packages such as libglu1-mesa on Ubuntu/Debian and mesa-libGLU on Fedora
Look at Flutter sdk path while Creating the Project.
$ C:\flutter
If your Flutter SDK is updated and the path is right you will get a solution.
Check your Flutter SDK path.
Check the package name. It must be in lower case.
Restart your IDE and check again.

Flutter Doctor found issue Android_Home

I am trying to setup Flutter in windows 10.
I have:
Android Studio installed
Visual Studio Code
When I run "andoid doctor" in command prompt is shows no errors:
But When I try to configure VSCode Editer with steps given in https://flutter.io/get-started/editor/
It Throws error as show below:
I tried after setting environment variable as:
ANDROID_HOME = F:\Program Files\Android
Even after setting the above I get the same error.
My device was not getting detected by VS Code so , when i searched i found you need to set Android sdk location in Flutter environment for VS code to detect Device so i went to Flutter sdk folder C:\Research\flutter and double clicked on flutter_console which opened a Flutter console and run command
flutter config --android-sdk C:\Users\annur.arya\AppData\android-sdk and now it works
I just added a solution because the solution is not clear in the comments
You have to use this command to set the ANDROID_HOME to your SDK path
export ANDROID_HOME="YOUR_SDK_PATH"
According to this discussion, some people had to set both ANDROID_HOME and ANDROID_SDK_ROOT to SDK path just like this
export ANDROID_SDK_ROOT="YOUR_SDK_PATH"
export ANDROID_HOME=$ANDROID_SDK_ROOT
It's possible that ANDROID_HOME is not set to the same value in both of these cases; try running echo %ANDROID_HOME both in the location that works and the terminal where it doesn't. If these values are different, you'll need to figure out why (my guess would be that either you've changed it and not rebooted, or it's being set in a startup script that's only running in one of the contexts).
I had the same problem,
I did the following steps :
*/ Open system properties
*/ Environment variables
*/ create new system variable
*/ name : ANDROID_HOME
*/ value : copy your SDK path
*/ close your current cmd, and restart it
*/ run flutter doctor
this should work on windows
You can look in ~/.config/flutter/settings in Linux to manually configure the folder.
GO to Project Structure
set Project SDK to 31 API Or any one 30,29 etc..
and then click Ok

Resources