简体   繁体   中英

flutter can not find android sdk?

i have installed flutter on ubuntu 18.04 and i also have installed android studio which works fine but when i runs flutter doctor. flutter is not able to find android tool chain. and also has red cross before dart plugin and flutter plugin. i don't know why this happening. i have installed flutter plugin and dart plugin as well.but red cross is still there.

here is out come of flutter doctor

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, set
      ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM