Flutter Doctor报告错误Android工具链-为Android设备开发

时间:2019-12-26 07:05:19

标签: flutter android-sdk-2.3

我在Mac上运行flutter doctor: 以下是一个问题:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14 18A391, locale
    zh-Hans-CN)
[✗] 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/setup/#android-setup for detailed
      instructions).
      If the Android SDK has been installed to a custom location, set
      ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

但是我已经在Mac上通过以下路径/Users/delo/software/android-sdk-macosx安装了Android SDK。

在问这个问题之前,我已经按照this post在我的/Users/delo/software/android-sdk-macosx文件中添加了/etc/paths.d/android-sdk,并this post添加了path-to-android-sdk/toolspath-to-android-sdk/platform-tools

但是仍然存在这个问题。


EDIT-01

这是echo $PATH

/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/delo/.rvm/gems/ruby-2.3.3/bin:/Users/delo/.rvm/gems/ruby-2.3.3@global/bin:/Users/delo/.rvm/rubies/ruby-2.3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/delo/software/android-sdk-macosx:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/opt/local/bin:/usr/local/mysql/bin:/usr/local/Cellar/go/1.7.6/bin:/Users/delo/.rvm/bin:/usr/local/sbin:/Users/delo/software/android-sdk-macosx/tools:/Users/delo/software/android-sdk-macosx/platform-tools

1 个答案:

答案 0 :(得分:0)

我看到您的$ PATH添加了ANDROID SDK PATH及其toolsplatform-tools PATH,但是没有配置flutter PATH,但是您仍然可以运行flutter doctor命令,应该是复制错误。

根据您的情况,必须存在ANDROID_HOME变量配置错误

您应该遵循正确的方法:

追加

export PATH=/path/to/your/flutter/bin:$PATH
export ANDROID_HOME="/path/to/your/android-sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

然后您只需source ~/.bash_profile