Reputation: 16240
I have installed flutter
through AUR. I also have aur/android-sdk 26.0.2-1
installed. When I run flutter run
I get:
Warning! This package referenced a Flutter repository via the .packages file that is
no longer available. The repository from which the 'flutter' tool is currently
executing will be used instead.
running Flutter tool: /home/dair/.flutter-sdk
previous reference : /home/dair/flutter
This can happen if you deleted or moved your copy of the Flutter repository, or
if it was on a volume that is no longer mounted or has been mounted at a
different location. Please check your system path to verify that you are running
the expected version (run 'flutter --version' to see which flutter is on your path).
Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.
Firstly, I ran flutter --version
, and received:
Flutter • channel alpha • https://github.com/flutter/flutter.git
Framework • revision e2f54df5ab (9 days ago) • 2017-06-02 10:43:54 -0700
Engine • revision 1f2aa07571
Tools • Dart 1.24.0-dev.3.0
Not sure what exactly it means by "to see which flutter is on your path". Next I ran flutter doctor
and got:
[✓] Flutter (on Linux, locale en_US.UTF-8, channel alpha)
• Flutter at /home/christopher/.flutter-sdk
• Framework revision e2f54df5ab (9 days ago), 2017-06-02 10:43:54 -0700
• Engine revision 1f2aa07571
• Tools Dart version 1.24.0-dev.3.0
[✗] Android toolchain - develop for Android devices
✗ ANDROID_HOME = /opt/android-sdk
but Android SDK not found at this location.
[✓] Android Studio (version 2.3)
• Android Studio at /usr/local/android-studio
• Gradle version 3.2
• Java version: OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] Connected devices
• None
However, if I cd into /opt/android-sdk
I get:
➜ ~ cd /opt/android-sdk
➜ android-sdk ls
add-ons build-tools emulator platforms tools
So it looks like it is there. The closest question I could find is this one: React Native android build failed. SDK location not found but it seems to be using Mac as opposed to arch as well as some other differences. How can I resolve the flutter doctor
and have my app run?
Upvotes: 99
Views: 301097
Reputation: 15237
I was running into the same problem when I was trying the flutter doctor
command:
The problem is a little clearer: it's occurring because Flutter is not finding the path for your Android SDK.
There are two ways to solve it:
You can solve this issue by setting the SDK path for your current terminal instance with the following commands:
flutter config --android-sdk /path/to/android/sdk
flutter config --android-studio-dir /path/to/android/studio
Or to save it permanently, export the ANDROID_HOME
with your Android SDK path.
I solved it by exporting the ANDROID_HOME
on my machine (Arch Linux, but this works for any Unix instance).
This will solve your issue, but you may need the sdk
, platform-tools
, tools
, and the ndk-build
paths as well (of course, everything needs to be installed first) in your profile file (in my case, the .zshrc
file; the same can be done in your .bashrc
, etc.):
# SDK exporting - this will solve your issue
export ANDROID_HOME=/home/{user}/Android/Sdk
# Tools exporting - it may be needed in your case
export PATH=/home/{user}/Android/Sdk/platform-tools:$PATH
export PATH=/home/{user}/Android/Sdk/tools:$PATH
export PATH=/home/{user}/Android/ndk-build:$PATH
# Flutter binary exporting
export PATH=/home/{user}/flutter/bin:$PATH
Then, I reloaded my profile file (in my case, the .zshrc
file; use your file in your case, e.g., .bashrc
):
source ~/.zshrc
After that, the flutter doctor
command will run properly.
Upvotes: 139
Reputation: 1678
For me, the Android SDK command-line tools were missing, i.e. installing Android Studio did not install the command-line tools automatically.
I had to run Android studio and use the included SDK manager to install the Android SDK Command-line Tools
Start Android Studio, select More Actions... > SDK Manager, select the SDK Tools tab, make sure to check Android SDK Command-line Tools (latest), click Apply. This will install the Android SDK command-line tools.
After that, flutter doctor
completed successfully. No need to set flutter config --android-sdk ...
etc.
$ uname -a
Linux x220 6.1.0-7-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.20-2 (2023-04-08) x86_64 GNU/Linux
Upvotes: 1
Reputation: 2627
I experienced the same issue and solved it with these simple steps:
flutter config --android-sdk pastetheAndroidSDKlocationpathhere
.flutter doctor
.Upvotes: 0
Reputation: 24087
I'm going to write my experience here on a mac. The real difference to the other answers is that I was confused as to where the installs were, where they should be found and also how confusion was caused by multiple versions of both Android Studio & the sdk existing on my mac.
You to need find two main directories; the sdk location and the installation directory of Android Studio.
The sdk seemed to have been installed twice and referenced in different places. One of which was installed by brew
so I uninstalled that one. The one I ended up referencing is the following. I think that is the proper location on a mac (don't use brew)
/Users/myusername/Library/Android/sdk/
Run this command
flutter config --android-sdk sdk_path_here
and set these environment & path variables
export ANDROID_HOME=sdk_path_here
export PATH=sdk_path_here/platform-tools:$PATH
export PATH=sdk_path_here/tools:$PATH
flutter config --android-studio-dir=/Applications/Android\ Studio.app
but I had updated to the JetBrains Toolbox so mine was installed there (I uninstalled the other version of Studio). The one I referenced was
/Users/yourusername/Applications/JetBrains\ Toolbox/Android\ Studio.app
So I ran the following to set the Android Studio location
flutter config --android-studio-dir=/Users/yourusername/Applications/JetBrains\ Toolbox/Android\ Studio.app
After that I still was presented with an error but I restarted my whole machine, deleted previously created AVDs in Studio's Device Manager and then everything did indeed work as expected.
Upvotes: 0
Reputation: 23
We need to fix this in the tool. You can work around this locally by running flutter config --android-studio-dir='C:\Program Files\Android\Android Studio'
, which you can check with explorer. For me this path is C:\Program Files\Android\Android Studio\
Upvotes: 0
Reputation: 2353
In my case, I have to accept the android licenses
run this command in the terminal or android studio terminal
flutter doctor --android-licenses
Upvotes: 0
Reputation: 45042
I had a similar error. Adding Flutter path of extracted flutter sdk till flutter fixed it
Upvotes: 0
Reputation: 724
flutter config --android-studio-dir <path where android studio is installed>
In my case it was "C:\Program Files\Android\Android Studio"
try with double quotes in the command( I tried with double quotes, which might be necessary if there is space in the path)
Source: https://flutter.dev/docs/get-started/install/windows#android-setup
Upvotes: 3
Reputation: 408
For Windows: Inside Android Studio, get path from : Apprearance & Behaviour > System Settings > Android SDK > Android SDK path
Make sure your path does not contain any spaces in them, if you have edit path and re-install sdk to a different location.
After that,
flutter config --android-sdk {path}
flutter doctor --android-licenses
You are set!
Upvotes: 26
Reputation: 567
Under Windows 10 (without Android Studio) I noticed that folder 'sdk/build-tools' is empty. Then I solved this problem by executing:
sdkmanager build-tools;30.0.3
where 'build-tools;30.0.3' was obtained in an output of "sdkmanager --list >list.txt" command.
And, after build-tools's installation the error "Android SDK cannot be found by flutter" was solved too!
PS. It is absolutely essential to read carefully the documentation (there were although another mistakes by me)
PS.PS. The log (for illustration):
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.17763.1697], locale ru-UA)
[!] Android toolchain - develop for Android devices
X 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/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
X No valid Android SDK platforms found in d:/Android\SDK\platforms. Candidates were:
- android-13
- android-19
- android-23
- android-29
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = d:\Android
X Unable to find bundled Java version.
[√] VS Code (version 1.53.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
C:\Users\Леон>sdkmanager build-tools;30.0.3
[=======================================] 100% Unzipping... android-11/renderscr
C:\Users\Леон>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.17763.1697], locale ru-UA)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = d:\Android
X Unable to find bundled Java version.
[√] VS Code (version 1.53.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
C:\Users\Леон>
Upvotes: 0
Reputation: 1055
As mentioned above by others, using the below command works:
flutter config --android-sdk /path/to/android/sdk
Remember to put quotes in the /path/to/android/sdk
Example: flutter config --android-sdk "C:\Users\UserName\AppData\Local\Android\Sdk"
Upvotes: 0
Reputation: 33
You Can follow the first answer above. I would like to add a tip. If you are on windows and installed sdk on a path that requires admin rights to modify, then flutter doctor might fail to recognise the sdk. Copy the sdk folder to another non-admin location and then run flutter config --android-sdk command.
Upvotes: 0
Reputation: 1
for me, it was very simple.
this kind of issue usually happens if IDE unable to load SDK
.
so to solve this follow below steps:
goto file menu
-> project structure
-> project settings
-> select "project"
now set Android SDK path with existing java version.
then select "modules" and configure Android SDK and click on apply and then click ok.
now we may find both ios and android emulators to run your flutter app on both devices.
Upvotes: 0
Reputation: 2132
If you're using Android Studio 3, you can configure your platform SDK by going to File -> Project structure and choose your platform SDK.
Hope this works for you.
Upvotes: 65
Reputation: 1
For Windows 10 Version 2004
I added a user environment variable named ANDROID_HOME
and value is {SDK-PATH}\build-tools\{SDK-VERSION}
. You have to replace SDK-PATH and SDK-VERSION for your custom values.
And I appended another value named %ANDROID_HOME%
to system PATH
variable.
Then it worked as expected.
Upvotes: 0
Reputation: 904
For macOS Catalina:
If you have installed android sdk to a custom location (say /Users/your_username/dev/android/sdk
) then follow these steps (NOTE: You must change the location according to your sdk location):
Open zshrc file
nano ~/.zshrc
Add the following to the zshrc file
export ANDROID_HOME=Users/your_username/dev/android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
Save and close nano using Ctrl+x
, when prompted type y
Source your zshrc file using
source $HOME/.zshrc
You can check whether your problem is fixed by typing the following in a terminal window. You should get the sdk path as your output
echo $ANDROID_SDK_ROOT
Upvotes: 0
Reputation: 543
Go to the project structure and make sure the sdk version is selected.
Upvotes: 5
Reputation: 1056
in environment variables
make
Variables: ANDROID_HOME
and add path of SDK get from Andriod stideo --> settings --> SDK Coppy the Path examlpe
:C:\Users\Omar\AppData\Local\Android
Add the SDK path in variables Value: C:\Users\Omar\AppData\Local\Android
Next Step: Add 2 value in path variables :
%ANDROID_HOME%\tools
%ANDROID_HOME%\platform-tools
Upvotes: 0
Reputation: 6045
To get the Android SDK path - Open Flutter project in Android Studio - Go to File > Project Structure > SDK Location. Copy the location
To set the Android SDK path
- Type in terminal flutter config --android-sdk /path/that/you/just/copied
Upvotes: 11
Reputation: 51
I've set up my Android SDK manually on Windows 10 with the command line, I think this not change a lot in Linux, and I was able to solve this kind of errors while I tried to set up my development environment, if you want to solve it as I did, just follow the next steps that I posted in a GitHub Comment in a related issue:
https://github.com/flutter/flutter/issues/19805#issuecomment-478306166
I hope this can help anyone need it! Bye!
Upvotes: 0
Reputation: 131
The solution at https://github.com/flutter/flutter/issues/15114#issuecomment-376582281 worked for me, this worked after adding $ANDROID_SDK_PATH\platform-tools to user path variable.
Upvotes: 1
Reputation: 81
I suffered alot trying to find a solution to it and finally I found the solution by configuring the project SDK
File -> Project structure then choose sdk platform.
Upvotes: 8
Reputation: 197
i have solved! i put my android SDK before in F:/androidsdk so when i run "flutter config" android sdk doesnt linked. To link flutter wiht android sdk just type command below:
flutter config --android-sdk /path/to/android/sdk
i just change with this
flutter config --android-sdk F:/androidsdk
i hope this is working.
Upvotes: 11
Reputation: 3906
It is saying that your project is using two different path of flutter-sdk. There are two place where sdk paths are defined.
These both place should contain same path to sdk.Compile with flutter run
!! done !!
Upvotes: 1
Reputation: 369
I have solved this problem by the following command
flutter config --android-sdk <sdk-location>
Where is the location for your sdk. If you're on windows make sure to use double quotes.
Upvotes: 36
Reputation: 116708
Flutter requires the Android SDK platform tools so that it can use the adb
command line tool.
It looks like you've installed the Android SDK but you haven't installed the platform tools yet.
Here is the android-sdk-platform-tools Aur package for arch and a guide for how to install it.
Possibly the error message could be improved to indicate that we are actually missing the Android SDK platform tools rather than the Android SDK itself. If you want to, feel free to send a pull request or open an issue.
Upvotes: 3