I'm setting up an application development environment with Flutter.
I'm having trouble installing Android Studio: I can't set the directory where Android Studio is installed. I've got an error, as shown in the picture. How do I find the correct directory?
You default Android Studio directory should be C:\Program Files\Android\Android Studio.
If you are searching for the Android SDK location, check out here.
The warning/error you are getting on flutter doctor is telling you that he cannot find Android Studio in the path C:\Program, this means you will need to set it manually. To do it, run the following command(s) with the correct path.
flutter config --android-studio-dir "[YOURPATH]"
flutter config --android-sdk "[YOURPATH]"
This should be the expected output of the flutter doctor
Remember to use those " " to indicate the path of Android Studio, otherwise you'll have this output, that is not what we want: Setting "android-studio-dir" value to "C:\Program".
flutter config --android-studio-dir = C:\Program Files\Android\Android Studio
Which unfortunately does not work because of empty space which breaks the tree structure
To resolve this, type the command below which will reset the default.
flutter config --android-studio-dir=""
Related
I have added
"C:\Program Files\Git\bin;C:\Program
Files\Git\cmd;C:\tools\dart-sdk;C:\Windows\System32;C:\Windows\System32\wbem;C:\src\flutter\bin;C:\tools\dart-sdk\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;"
in my environtment variables path. That's succesfull when i run flutter doctor in my powershell, but if i run in powershell in vscode, that error occured. The effect is i can't make a new flutter project in vs code and also in android studio.
i can run flutter doctor in my windows powershell
i can't run flutter doctor in my vscode powershell
run flutter doctor and make a new flutter project in vscode and android studio
As I can see, in the powershelgl, you're running on the C drive and in VSCode, it's running on the F drive where flutter is not installed.. This is probably causing the issue.
Hope you find this helpfull.
I'm on Ubuntu 20.04 LTE
My Android SDK Location (shown in Android studio) is /home/myuser/Android/Sdk
The error goes as follows:
✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
What I did to try to fix it:
Fresh installs of both Flutter (via snap) and Android studio (via apt, because when I install it also via snap, Flutter can't find even Android studio then).
Set configs:
flutter config --android-sdk="/home/myuser/Android/Sdk"
flutter config --android-studio-dir="/opt/android-studio-2021.1.1/android-studio"
Set paths in .bashrc:
export ANDROID_HOME=$HOME/Android/Sdk/
export PATH=$PATH:$ANDROID_HOME/tools/
export PATH=$PATH:$ANDROID_HOME/platform-tools/
In Android studio, I installed:
Dart and Flutter plugins.
SDK Platforms: 9.0(Pie), 10.0(Q), 11.0(R), 12.0(S), Android API 32
SDK Tools:
Android SDK Build-Tools 33-rc2
Android SDK Command-line Tools (latest)
Android Emulator 31.2.9
Android SDK PLatform-Tools 33.0.1
Trying to do flutter doctor --android-licenses doesn't do anything as it can't find Android SDK.
And I also can't run flutter doctor without adding sudo, because it stops after the first result and then runs for infinity.
Go to SDK tools and install all Support Repositories. Also check if there are any empty folders inside your SDK folder, if there are any empty folders, please delete them.Then follow the usual steps you mentioned,
Setting the config,
flutter config --android-sdk "/home/myuser/Android/Sdk"
Then finally run the flutter doctor again.
I use ubuntu too and the below is my environment.
Please try something like this in your vim ~./bashrc or vim ~/.zshrc
Change the paths as it is in your environment:
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
export PATH=$PATH:~/development/flutter/bin
if it doesn't work try installing Flutter manually:
https://docs.flutter.dev/get-started/install/linux#install-flutter-manually
As the error message says, ANDROID_SDK_ROOT or previously known as ANDROID_HOME are not set in your environment variables.
To fix that, you will need to:
export ANDROID_SDK_ROOT=/path/to/android/studio/installation
export ANDROID_HOME=/path/to/android/studio/installation
export PATH=$PATH:/path/to/android/studio/installation
Due to some legacy reasons, there are a few variables pointing to the same thing. To make sure your Flutter SDK is getting it, you can set all of them.
Note: if you don't want to set them every time your laptop reboots, feel free to add them into ~/.bashrc.
Theoretically, during the installation of Android Studio, the variables above should be set for you, but, in reality, it doesn't always happen which is the reason you are seeing the error message.
Not sure but maybe the problem is caused by snap, since it was sandboxing the applications you install. I remember having a problem like this on something different. You can try installing flutter manually (downloading the zip and so on...) rather than using snap.
I am getting this error code in my Visual Studio Code. How can I fix it?
I am using Flutter v2.5.3.
You can try fixing it by running this in the terminal:
Just copy and paste the below code into the terminal and run it.
dart pub global activate devtools -v 2.8.0
which downgrades the version to 2.8.0 (that works fine). I found the answer on GitHub.
I agree with RandomCoder's answer to avoid executing command
dart pub global activate devtools -v 2.8.0
every time before opening Visual Studio Code.
And also if you didn't know the location of the build folder mentioned by RandomCoder, I found the location after reading it here for the pub cache folder:
By default, this directory is located under . pub-cache in your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows). (The precise location of the cache may vary depending on the Windows version.)
After you found it, go to the \hosted\pub.dartlang.org\devtools-2.8.0 directory to copy the build version there and paste it in \hosted\pub.dartlang.org\devtools-2.9.2.
I still didn't know if there is any bad effects of copy pasting it to a newer version folder, but in my case it's working until now.
In my case there wasn’t any build folder in the devtools-2.9.2 folder.
I copied it from 2.8.0 and it now works.
For Android Studio
Close Android Studio
Rn dart pub global activate devtools -v 2.8.0 to downgrade (as suggested in a previous answer)
Open Android Studio
Run your build
For Visual Studio Code
Open Terminal
Run dart pub global activate devtools -v 2.8.0 to downgrade (as suggested a previous answer)
I fix this by:
flutter upgrade
This is an issue coming since yesterday. Maybe they must have updated the Dart engine.
There are two ways which will help you to solve the issue.
Update the Flutter SDK to the latest version and restart your PC:
flutter upgrade
Use the Dart Devtools manually
Run flutter pub global in another terminal. Run devtools and then open http://127.0.0.1:9100
Enter a running application field address of your running application in the Connect: "http://127.0.0.1:60230/J7_wS_YhTuo=/"
You can find this URL in debug console when you run the code.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:51849/mHlycLJYEWw=/ws
If you are getting any issue regarding the port, then do this in your Flutter project console
flutter run --observatory-port=9100
Once the application starts you can see the message in the console.
If you are getting any server issue in the web browser
then enter
dart devtools
In cmd
Downgrade to devtools-2.8.0
And activate using dart pub global activate devtools -v 2.8.0
These two steps worked in my case
First activate your devtool using this command...
flutter pub global activate devtools
flutter pub global run devtools
And after that, try launching it from Visual Studio Code as described in the documentation: Install and run DevTools from VS Code
I'm trying to configure the path to Android Studio on my Windows.
I'v tried these commands:
flutter config --android-sdk /path/to/android/sdk
and
flutter config --android-studio-dir /path/to/android/studio
but second didn't work.
I can't change path because it gets cut in cmd.
I've tried to uninstall and re-install flutter SDK, but it didn't fix the flutter doctor errors.
I understood that with ANDROID_HOME already set it was really foolish to implement these commands...
Is this path to android studio correct?
I've zero skills in programming, so I don't even know the basics
run in cmd :
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
I'm new to coding and recently tried to install flutter framework in git bash but there was a warning about android studio , by mistake I copied a line of code from the internet
flutter config --android-studio-dir=/my/local/path/for/android/studio
which intern is giving a new warning saying
X android-studio-dir = C:/Program Files/Git/my/local/path/for/android/studio
X Android Studio not found at C:/Program Files/Git/my/local/path/for/android/studio
please, anyone, help me
I tried to write the same code giving the value of the location where the android studio is present but it did not work
Type flutter config -h for help.
It says
To remove a setting, configure it to an empty string.
or you can set the correct value as
flutter config --android-studio-dir='correct/path/'
run flutter doctor when done