简体   繁体   English

Flutter Doctor 无法识别我的 ANDROID_SDK 环境变量

[英]Flutter Doctor not recognizing my ANDROID_SDK environment variables

I have the android-sdk installed from ubuntu's repository but it does not contain the sdkmanager executable and isn't current enough to be compatible with flutter, so I installed the wrapper from snapd that contains it.我从 ubuntu 的存储库安装了 android-sdk,但它不包含sdkmanager可执行文件,并且还不足以与颤振兼容,所以我从包含它的 snapd 安装了包装器。 According to the documentation I have to change my ANDROID_SDK_ROOT env.根据文档,我必须更改我的ANDROID_SDK_ROOT环境。 variable so that it works with it.变量,以便它与它一起工作。 I have also read that I need to set ANDROID_HOME to the directory (I think it's deprecated but just in case) so I put this in my .profile :我还读到我需要将ANDROID_HOME设置为目录(我认为它已被弃用,但以防万一)所以我把它放在我的.profile中:

export ANDROID_SDK_ROOT=/snap/androidsdk/current/
export ANDROID_HOME=/snap/androidsdk/current/

I then ran source .profile and restarted my machine, however flutter doctor kept giving me this error:然后我运行了source .profile并重新启动了我的机器,但是颤振医生一直给我这个错误:

[!] Android toolchain - develop for Android devices (Android SDK version 27.0.1)
    ✗ Flutter requires Android SDK 29 and the Android BuildTools 28.0.3
      To update the Android SDK visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.

I know that it's using the wrong path because when I run flutter doctor --android-licenses I receive this error:我知道它使用了错误的路径,因为当我运行flutter doctor --android-licenses时收到此错误:

Android sdkmanager tool not found (/usr/lib/android-sdk/tools/bin/sdkmanager).

Which points to the path of the the SDK I installed with apt.它指向我用 apt 安装的 SDK 的路径。 I have tried flutter config --android-sdk $PATH_TO_SDK but that still has not changed anything.我已经尝试过flutter config --android-sdk $PATH_TO_SDK但这仍然没有改变任何东西。 Is there a ppa that contains the sdk manager so that I don't have to try and configure flutter to use the snapd androidsdk or is there something I'm missing/doing wrong?是否有一个包含 sdk 管理器的 ppa,这样我就不必尝试配置颤振来使用 snapd androidsdk 或者我缺少/做错了什么?

OS: Ubuntu 20.04操作系统:Ubuntu 20.04

androidsdk (snapd) version: 30 (I would prefer not to use this) androidsdk (snapd) 版本:30(我不想用这个)

android-sdk (apt) version: 25.0.0 (Which is also below flutter's requirements) android-sdk (apt) 版本:25.0.0(也低于flutter的要求)

I have the android-sdk installed from ubuntu's repository but it does not contain the sdkmanager executable and isn't current enough to be compatible with flutter, so I installed the wrapper from snapd that contains it.我从 ubuntu 的存储库安装了 android-sdk,但它不包含sdkmanager可执行文件,并且当前不足以与 flutter 兼容,因此我从包含它的 snapd 安装了包装器。 According to the documentation I have to change my ANDROID_SDK_ROOT env.根据文档,我必须更改ANDROID_SDK_ROOT variable so that it works with it.变量,以便它与它一起工作。 I have also read that I need to set ANDROID_HOME to the directory (I think it's deprecated but just in case) so I put this in my .profile :我还读到我需要将ANDROID_HOME设置为目录(我认为它已被弃用,但以防万一)所以我把它放在我的.profile

export ANDROID_SDK_ROOT=/snap/androidsdk/current/
export ANDROID_HOME=/snap/androidsdk/current/

I then ran source .profile and restarted my machine, however flutter doctor kept giving me this error:然后我运行source .profile并重新启动我的机器,但是 flutter doctor 一直给我这个错误:

[!] Android toolchain - develop for Android devices (Android SDK version 27.0.1)
    ✗ Flutter requires Android SDK 29 and the Android BuildTools 28.0.3
      To update the Android SDK visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.

I know that it's using the wrong path because when I run flutter doctor --android-licenses I receive this error:我知道它使用了错误的路径,因为当我运行flutter doctor --android-licenses我收到此错误:

Android sdkmanager tool not found (/usr/lib/android-sdk/tools/bin/sdkmanager).

Which points to the path of the the SDK I installed with apt.其中指向我用apt安装的SDK的路径。 I have tried flutter config --android-sdk $PATH_TO_SDK but that still has not changed anything.我试过flutter config --android-sdk $PATH_TO_SDK但这仍然没有改变任何东西。 Is there a ppa that contains the sdk manager so that I don't have to try and configure flutter to use the snapd androidsdk or is there something I'm missing/doing wrong?是否有一个包含sdk管理器的ppa,这样我就不必尝试配置flutter以使用已捕捉的androidsdk,还是我缺少/做错了什么?

OS: Ubuntu 20.04操作系统:Ubuntu 20.04

androidsdk (snapd) version: 30 (I would prefer not to use this) androidsdk (snapd) 版本:30(我不想使用这个)

android-sdk (apt) version: 25.0.0 (Which is also below flutter's requirements) android-sdk (apt) 版本:25.0.0(也低于 flutter 的要求)

You were using the wrong path for ANDROID_HOME您为 ANDROID_HOME 使用了错误的路径

Android Studio is not necessary: Android Studio 不是必需的:

After installing flutter with snap and ensuring "\/snap\/bin" is in your path:在使用 snap 安装 Flutter 并确保“\/snap\/bin”在您的路径中之后:

  1. sudo snap install androidsdk sudo snap install androidsdk<\/li>
  2. As regular user: androidsdk "platform-tools" "platforms;android-29" "build-tools;30.0.2"作为普通用户:androidsdk "platform-tools" "platforms;android-29" "build-tools;30.0.2"<\/li><\/ol>

    This will install the android sdk tools you need into "$HOME\/AndroidSDK"这会将您需要的 android sdk 工具安装到“$HOME\/AndroidSDK”中

    1. export ANDROID_HOME="$HOME\/AndroidSDK"导出 ANDROID_HOME="$HOME\/AndroidSDK"

      <\/li>

    2. flutter doctor扑医生

      <\/li><\/ol>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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