skip to Main Content

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:

  1. 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).
  2. Set configs:
    • flutter config --android-sdk="/home/myuser/Android/Sdk"
    • flutter config --android-studio-dir="/opt/android-studio-2021.1.1/android-studio"
  3. Set paths in .bashrc:
    • export ANDROID_HOME=$HOME/Android/Sdk/
    • export PATH=$PATH:$ANDROID_HOME/tools/
    • export PATH=$PATH:$ANDROID_HOME/platform-tools/
  4. 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
  5. 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.

4

Answers


  1. 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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search