Android SDK cannot be found by flutter
AndroidFlutterAndroid Problem Overview
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: https://stackoverflow.com/questions/32634352/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?
Android Solutions
Solution 1 - Android
I was running with the same problem when I was trying the flutter doctor
command:
The problem is a little clear, it's occurring because the flutter is not founding the path for your Android SDK.
There are two ways to solve it:
-
You can solve this issue setting only for your current terminal instance the SDK path 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 forever, exporting 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 can need the sdk
, platform-tools
, tools
and the ndk-build
paths too (of course, everything needs to be installed first) on my profile file (in my case the .zshrc
file, the same can be done on your .bashrc
and etc.):
#SDK exporting - this will solve your issue
export ANDROID_HOME=/home/{user}/Android/Sdk
#Tools exporting - it can be need 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 (that in my is the .zshrc
file, use your file in your case .eg .bashrc
):
source ~/.zshrc
After that, the flutter doctor
will run properly.
Solution 2 - Android
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.
Solution 3 - Android
I have solved this problem by the following command
flutter config --android-sdk <sdk-location>
Where
Solution 4 - Android
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!
Solution 5 - Android
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
Solution 6 - Android
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.
Solution 7 - Android
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.
Solution 8 - Android
Solution 9 - Android
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.
Solution 10 - Android
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
Solution 11 - Android
It is saying that your project is using two different path of flutter-sdk. There are two place where sdk paths are defined.
- Setting (Setting > Language&Frameworks > Flutter > Flutter SDK path)
- local.properties in your root folder
These both place should contain same path to sdk.Compile with flutter run
!! done !!
Solution 12 - Android
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.
Solution 13 - Android
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!
Solution 14 - Android
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
Solution 15 - Android
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 typey
-
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
Solution 16 - Android
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.
Solution 17 - Android
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.
Solution 18 - Android
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
Solution 19 - Android
Windows command to fix SDK path
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"
Solution 20 - Android
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\Леон>
Solution 21 - Android
Solution 22 - Android
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\
Solution 23 - Android
In my case, I have to accept the android licenses
run this command in the terminal or android studio terminal
flutter doctor --android-licenses