[android] Flutter does not find android sdk

I just tried intalling flutter and since I already had android studio and the android sdk installed I just followed the installation of flutter. Here is my problem: When I run

flutter doctor

It tells me

  [v] Flutter (Channel beta, v0.1.5, on Microsoft Windows [Version 10.0.16299.248], locale en-US)
    • Flutter version 0.1.5 at C:\Users\Name\git\flutter
    • Framework revision 3ea4d06340 (2 weeks ago), 2018-02-22 11:12:39 -0800
    • Engine revision ead227f118
    • Dart version 2.0.0-dev.28.0.flutter-0b4f01f759

[X] Android toolchain - develop for Android devices
    X ANDROID_HOME = C:\Users\Name\AppData\Local\Android\sdk\Android
      but Android SDK not found at this location.

[v] Android Studio (version 3.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

Which tells me that flutter is not finding my Android sdk (even though it is the path that android studio uses aswell - and android studio is working fine)

I already tried reinstalling the sdk but it did not work.

Im very thankful for any help with this.

The answer is


Kindly first of all check your latest sdk first step: install latest Sdk platform

second step: Install all these licenses

Now Run

run flutter doctor --android-licenses Press Y against each agreement

run flutter doctor flutter doctor it will work fine.


Flutter provides a command to update the Android SDK path:

flutter config --android-sdk < path to your sdk >

OR

If you are facing this issue --> sdk file is not found in android-sdk\build-tools\28.0.3\aapt.

You may have probably not installed build tools for this Api level, Which can be installed through this link https://androidsdkmanager.azurewebsites.net/Buildtools


First run flutter upgrade from your terminal , If you get the following error,

ANDROID_HOME = C:\Users\Name\AppData\Local\Android\sdk\Android
      but Android SDK not found at this location.
  1. First go to android studio, Settings->System Settings->Click the expand arrow
  2. Then go to the Android SDK option and add the corresponding SDK to the project then go to Project Structure and add the respective SDK to the project Structure
  3. Then run flutter upgrade in the terminal

First open Android SDK Manager and make sure the required SDK's are installed.

enter image description here

Now open SDK manager, copy the SDK path. Open cmd

cd C:\Users\your-username\AppData\Local\Android\Sdk\build-tools

now again Change dir to the inner folder in build-tools. check the presence or the name issues of the aapt.exe file.


This solved my issue.

  • Step 1: In search type show hidden files and enable it.
  • Step 2: Go to C directoy> users>
  • Step 3: In that navigate to AppData>Local>Android>Sdk
  • Step 4: Copy the path to this folder
  • Step 5: Open power-shell and type in:

flutter config --android-sdk "C:\Users\<folder under your name>\AppData\Local\Android\Sdk"


flutter config --android-sdk F:\SDK


If you don't find the proper SDK path then, 1. Open Android Stidio 2. Go to Tools 3. Go to SDK Manager 4. You will find the "Android SDK Location"

Copy the path and edit the "Environment Variable" After it, restart and run the cmd. Then, run "flutter doctor" Hope, it will Work!


I assume this is this known issue https://github.com/flutter/flutter/issues/13750

You need to fix the path to the SDK manually until this is fixed in the file

my_flutter_project/android/local.properties

update

Add $ANDROID_HOME\sdk\tools and $ANDROID_HOME\sdk\platform-tools to the PATH environment variable.


For me, adding the Android SDK path didn't help.

I deleted all my SDKs (basically just deleted that Android folder. Used this path "C:\Users\your_user_name\AppData\Local\Android" to locate it.)

I then reinstalled all the required SDKs using android studio. (Be sure to install more than 1 SDK, I don't know why it doesn't work if you only install 1).

Then if I run Flutter Doctor, every thing works perfectly.


Deleting and reinstalling Android Studio fixes the issue with the SDK.


In my case, I had these Folders and relevant things inside of them (C:\Users\Name\AppData\Local\Android\Sdk\platforms)

enter image description here

and Error was this

enter image description here

Solution

Add System variables :

  1. Add folder paths of tools, build-tools, platform-tools to System variables -> Path

C:\Users\Name\AppData\Local\Android\Sdk\tools

C:\Users\Name\AppData\Local\Android\Sdk\build-tools

C:\Users\Name\AppData\Local\Android\Sdk\platform-tools

enter image description here

  1. After that, close previous flutter_console.bat (or refresh your ide) and open it again then run "flutter doctor"

enter image description here


SdkManager removes the API28 version and re-downloads the API28 version, setting the Flutter and Dart paths in AndroidStudio, and now it works fine. image


I have got following issue on Flutter Doctor command.

X Android SDK file not found: ..\Android\sdk\platforms\android-28\android.jar.

to fix this just go to Tools=> Android Sdk =>Update Sdk Platform for which issue is there.(I installed SDK 28).

check flutter document for this issue


this fix does not require any path change

question is below is the error we get on running flutter doctor

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ? Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses

The solution lies in the problem itself ------> flutter doctor --android-licenses

So what this command means is there are certain licenses which Google want the developer to accept as part of app development

To dig deep just run flutter doctor --android-licenses and keep typing y to accept all the license agreements once you have accepted all the agreements.

You'll see the following message on terminal "All SDK package licenses accepted"

now again re-run flutter doctor command

[?] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

you will see the tick sign this time


I solved this problem by below step,

1) go to -> system environment -> Environment Variables -> system Variable

2) create New Variable Name ANDROID_HOME and Value D:\Androidsdk\tools (custom android sdk path).

3) concat this path D:\Androidsdk\platform-tools in Path variable value using ";". (also in system Variable)

4) that's all, Restart the PC to apply changes and try again -- flutter Doctor.


export ANDROID_HOME=/usr/local/share/android-sdk/tools/bin
export PATH=$PATH:/usr/local/share/android-sdk/tools/bin

Choose the folder to install (I called it BASE_PATH) and use the following commands to install SDK with flutter:

Install SDK

cd $BASE_DIR
mkdir android-sdk
cd android-sdk
wget https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
unzip commandlinetools-linux-6200805_latest.zip
./tools/bin/sdkmanager --sdk_root=$(pwd) "build-tools;28.0.3" "emulator" "platform-tools" "platforms;android-28" "tools"

I used a separate folder for SDK, because it will add parent folders.

Install Flutter

cd $BASE_DIR
wget https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.12.13+hotfix.8-stable.tar.xz
tar xvf flutter_linux_v1.12.13+hotfix.8-stable.tar.xz

Export Vars (you can add them to your .bashrc)

export ANDROID_SDK=$BASE_DIR/android-sdk
export ANDROID_PATH=$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
export FLUTTER=$BASE_DIR/bin
export PATH=$PATH:$ANDROID_PATH:$FLUTTER

Check!

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel beta, v1.12.13, on Linux, locale en_US.UTF-8)
[?] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Android Studio (not installed)
[?] VS Code (version 1.31.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

Flutter say Sdk build tool version(exp:android toolchain - develop for android devices (android sdk 28.0.3)) version=28.0.3 go to home/username/Android/Sdk/build-tools delete this version(28.0.3) and fixed bug


What worked is Tools->Flutter->open Android module in Android studio, For me plugin flutter_email_sender was giving this error, so I copied local.properties file into it and the build become successful. enter image description here

Or Open Terminal Run touch ~/.bash_profile; open ~/.bash_profile

export ANDROID_HOME=/Users/<macusername>/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/<macusername>/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Run source ~/.bash_profile in android studio terminal


For mac users,

It was working fine yesterday, now the hell broke. I was able to fix it.

My issue was with ANDROID_HOME

// This is wrong. No idea how it was working earlier.
ANDROID_HOME = Library/Android/sdk 

If you did the same, change it to:

ANDROID_HOME = /Users/rana.singh/Library/Android/sdk 

.bash_profile has

export ANDROID_HOME=/Users/rana.singh/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Flutter is designed to use the latest Android version installed. So if you have an incomplete download of the latest Android, Flutter will try to use that.

So either complete the installation or delete the complete installation. You can find the Android versions at: /home/{user}/Android/Sdk/platforms/android-29/android.jar


I spent a lot of time solving this.

Eventually what worked was going to project settings in android studio, sdk tools, uncheck hide obsolete packages and install sdk tools obsolete package.

Then run flutter doctor --android-licenses and then flutter doctor showed a green tick on my android toolchain.

Hope this helps someone.


I've set up my Android SDK manually with the command line, 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!


You have to set ANDROID_HOME variable to SDK.

Create a new variable by the name and set it to the installation directory.

Make sure SDK is not below 2 subfolders from c drive or any windows root drive.


In my SDK folder there were a empty folder (/build-tools/29.0.0)

I deleted it, and it worked fine


To open Tools=> Android Sdkenter image description here Click SDK tools tab => check show package details and check all 28 SDK version install that and to fix the issue


We need to manually add the Android SDK. The instructions in the flutter.io/download say that the Android Studio 3.6 or later needs the SDK to be installed manually. To do that,

  1. Open the Android Studio SDK Manager
  2. In the Android SDK tab, uncheck Hide Obsolete Packages
  3. Check Android SDK Tools (Obsolete)

Please refer the Android Setup Instructions.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to flutter

Flutter Countdown Timer How to make an AlertDialog in Flutter? FlutterError: Unable to load asset Set the space between Elements in Row Flutter Flutter: RenderBox was not laid out Space between Column's children in Flutter How to change status bar color in Flutter? How can I add shadow to the widget in flutter? Flutter - The method was called on null Flutter- wrapping text

Examples related to android-sdk-tools

"Failed to install the following Android SDK packages as some licences have not been accepted" error Flutter does not find android sdk Failed to run sdkmanager --list with Java 9 You have not accepted the license agreements of the following SDK components Automatically accept all SDK licences Android SDK location should not contain whitespace, as this cause problems with NDK tools Finding Android SDK on Mac and adding to PATH Android SDK folder taking a lot of disk space. Do we need to keep all of the System Images? Daemon not running. Starting it now on port 5037 libz.so.1: cannot open shared object file

Examples related to android-sdk-manager

Flutter does not find android sdk Failed to run sdkmanager --list with Java 9 How do I download the Android SDK without downloading Android Studio? Android appcompat v7:23 Can't find SDK folder inside Android studio path, and SDK manager not opening