简体   繁体   English

无法定位 android SDK for flutter 医生

[英]Unable to locate android SDK for flutter doctor

I have tried uninstalling and reinstalling flutter on my computer twice but whenever I run flutter doctor in the terminal I am still met with the following error.我已经尝试在我的计算机上卸载并重新安装 flutter 两次,但是每当我在终端中运行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/macos#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.

Does anyone know how to fix this problem?有谁知道如何解决这个问题? Also, could this be the reason that none of my emulators are running my app?另外,这可能是我的模拟器都没有运行我的应用程序的原因吗? Thanks, and sorry, I am still new to Flutter and android studio.谢谢,抱歉,我还是 Flutter 和 android 工作室的新手。

If it is unable to locate your Android SDK, the reason might be that your Android SDK path is not up to date.如果找不到你的Android SDK,原因可能是你的Android ZF20E3C5E5E54C0AB3D36AZF6的路径没有更新到日期。

I think your issue is similar to this: https://github.com/flutter/flutter/issues/45007 .我认为您的问题与此类似: https://github.com/flutter/flutter/issues/45007

Try flutter config --android-sdk <path-to-your-android-sdk-path> to update the Android SDK path.尝试flutter config --android-sdk <path-to-your-android-sdk-path>来更新 Android SDK 路径。

This issue is related to environment variables.此问题与环境变量有关。

After entering the environment variables, you have to click on the system variables and find the "Path" variable.输入环境变量后,必须点击系统变量,找到“Path”变量。

Double click on the "Path" variable and add a new one on the right.双击“路径”变量并在右侧添加一个新变量。

There are two directories you need to add, "D: \ AndroidSDK \ platforms" and "D: \ AndroidSDK \ platform-tools".有两个目录需要添加,“D:\AndroidSDK\platforms”和“D:\AndroidSDK\platform-tools”。

These two directories can be in different places, remember this.这两个目录可以在不同的地方,记住这一点。

Faced the same issue when I moved my android studio to my external hard drive on my MacBook, here are steps I followed to fix当我将 android 工作室移动到我的 MacBook 上的外部硬盘驱动器时遇到了同样的问题,这是我修复的步骤

1 set the andriod sdk path flutter config --android-sdk example: flutter config --android-sdk /Volumes/Apps/Library/Android 1 设置安卓 sdk 路径 flutter config --android-sdk 示例:flutter config --android-sdk /Volumes/Apps/Library/Android

Once done it showed another error: Android license status unknown.完成后,它显示另一个错误:Android 许可证状态未知。 to fix this we need to add andriod studio directory, that is android studio app.要解决这个问题,我们需要添加 andriod studio 目录,即 android studio app。 Like this: flutter config --android-studio-dir example: flutter config --android-studio-dir /Volumes/Apps/Android\ Studio.app像这样: flutter 配置 --android-studio-dir 示例: flutter 配置 --android-studio-dir /Volumes/Apps/Android\ Studio.app

finally access the licensed from android studio, using below command and your are done.最后使用以下命令访问 android 工作室的许可,您就完成了。 flutter doctor --android-licenses flutter 医生 --android-licenses

If you do for example:例如,如果您这样做:

flutter config --android-sdk C:\Users\User\AppData\Local\Android\Sdk

and nothing happen, it is normal you have to double backslash like this:什么也没发生,你必须像这样加双反斜杠是正常的:

flutter config --android-sdk C:\\Users\\User\\AppData\\Local\\Android\\Sdk

For flutter 10.2.3 and Android Studio Bumblebee, I had to uninstall sdk using对于 flutter 10.2.3 和 Android Studio Bumblebee,我不得不使用卸载 sdk

File -> Settings > Appearance & Behavior -> system Settings -> Android SDK > SDK Platforms > uncheck all and apply.文件 -> 设置 > 外观和行为 -> 系统设置 -> Android SDK > SDK 平台 > 取消选中所有并应用。

After uninstall, I had remove to remaining contents in the Android SDK location manually.卸载后,我手动删除了 Android SDK 位置的剩余内容。

Then install again然后重新安装

File -> Settings > Appearance & Behavior -> system Settings -> Android SDK > SDK Platforms > Check Android API 32 -> apply文件 -> 设置 > 外观和行为 -> 系统设置 -> Android SDK > SDK 平台 > 检查 Android API 32 -> 应用

Install in SDK Tools tab -> expand Android SDK Build Tools -> 32.0.0 and Android Command Line tools (latest)在 SDK Tools tab -> 展开 Android SDK Build Tools -> 32.0.0 and Android Command Line tools (latest)

Then set然后设置

flutter config --android-sdk "path to your sdk root" flutter config --android-sdk “你的 sdk root 路径”

In my experience, flutter doctor reported an issue and failed to locate Android sdk (even having specified sdk path with flutter config --android-sdk ) also if there is a problem with any platform or build tool installed.根据我的经验,flutter 医生报告了一个问题并且未能找到 Android sdk(即使指定了 sdk 路径flutter config --android-sdk ),如果安装的任何平台或构建工具存在问题。

In my case the correct build-tools for my platform was missing and after installing it with sdkmanager also the issue related to sdk path in flutter doctor disappeared.在我的例子中,缺少适用于我的平台的正确build-tools ,并且在使用 sdkmanager 安装它之后,与sdkmanager医生中的 sdk 路径相关的问题也消失了。

My working android sdk configuration (based on Android platform 30) is:我的工作 android sdk 配置(基于 Android 平台 30)是:

  Path                 | Version | Description                    | Location            
  -------              | ------- | -------                        | -------             
  build-tools;30.0.3   | 30.0.3  | Android SDK Build-Tools 30.0.3 | build-tools/30.0.3  
  emulator             | 31.3.11 | Android Emulator               | emulator            
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4          
  platform-tools       | 33.0.3  | Android SDK Platform-Tools     | platform-tools      
  platforms;android-30 | 3       | Android SDK Platform 30        | platforms/android-30

Hope this helps anyone facing the same problem, having set the correct path to android sdk希望这可以帮助遇到同样问题的任何人,将正确的路径设置为 android sdk

For more clarity on how to add the path为了更清楚地了解如何添加路径

Run this for adding to path,运行此以添加到路径,

flutter config --android-sdk "path to your sdk root"

Example例子

flutter config --android-sdk "/Users/clovisokonkwo/androidSdk"

Then this for accepting license然后这是接受许可

flutter doctor --android-licenses

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

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