0

我正在 McBook air 进行全新安装,并且想在没有 Android Studio 的情况下在 Android 上使用 Flutter,所以我做了以下操作:

我下载flutter-sdk并将其添加到 permeant 路径中:

Hasans-Air:~ h_ajsf$ sudo code $HOME/.bash_profile

添加:

PATH=$PATH:/usr/local/Cellar/flutter/bin

然后,保存文件并运行:

Hasans-Air:~ h_ajsf$ source $HOME/.bash_profile

并通过运行确认添加:

Hasans-Air:~ h_ajsf$ echo $PATH

安装android-sdk

Hasans-Air:~ h_ajsf$ brew cask install android-sdk
==> Caveats
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:

  'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'

android-sdk requires Java 8. You can install it with

  brew cask install homebrew/cask-versions/java8

==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-433379
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'android-sdk'.
==> Installing Cask android-sdk
==> Linking Binary 'android' to '/usr/local/bin/android'.
==> Linking Binary 'archquery' to '/usr/local/bin/archquery'.
==> Linking Binary 'avdmanager' to '/usr/local/bin/avdmanager'.
==> Linking Binary 'jobb' to '/usr/local/bin/jobb'.
==> Linking Binary 'lint' to '/usr/local/bin/lint'.
==> Linking Binary 'monkeyrunner' to '/usr/local/bin/monkeyrunner'.
==> Linking Binary 'screenshot2' to '/usr/local/bin/screenshot2'.
==> Linking Binary 'sdkmanager' to '/usr/local/bin/sdkmanager'.
==> Linking Binary 'uiautomatorviewer' to '/usr/local/bin/uiautomatorviewer'.
==> Linking Binary 'mksdcard' to '/usr/local/bin/mksdcard'.
==> Linking Binary 'monitor' to '/usr/local/bin/monitor'.
  android-sdk was successfully installed!
Hasans-Air:~ h_ajsf$ 

Anroid-SDK_ROOT并按上述要求添加:

export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"

安装Platform-tools

Last login: Sat Nov 10 14:13:29 on ttys002
Hasans-Air:~ h_ajsf$ brew cask install android-platform-tools
==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/platform-tools_r28.0.1-
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'android-platform-tools'.
==> Installing Cask android-platform-tools
==> Linking Binary 'adb' to '/usr/local/bin/adb'.
==> Linking Binary 'dmtracedump' to '/usr/local/bin/dmtracedump'.
==> Linking Binary 'etc1tool' to '/usr/local/bin/etc1tool'.
==> Linking Binary 'fastboot' to '/usr/local/bin/fastboot'.
==> Linking Binary 'hprof-conv' to '/usr/local/bin/hprof-conv'.
==> Linking Binary 'mke2fs' to '/usr/local/bin/mke2fs'.
  android-platform-tools was successfully installed!
Hasans-Air:~ h_ajsf$ 

我已经安装了OpenJDK

$ brew cask install java

并添加JAVA_HOME

$ sudo code $HOME/.bash_profile

添加行:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands

这样我$HOME/.bash_profile就变成了:

PATH=$PATH:/usr/local/Cellar/flutter/bin
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands

然后运行:

$ source $HOME/.bash_profile

并通过以下方式确认添加:

Hasans-Air:lib h_ajsf$ echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands

以及Gradle

$ brew install gradle

并安装VS code为:

$ brew cask install visual-studio-code

在检查时flutter doctor,我得到了以下信息:

Hasans-Air:~ h_ajsf$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.14.1 18B75, locale en-SA)
[!] Android toolchain - develop for Android devices
    ✗ Android SDK is missing command line tools; download from 

当我运行命令env时,我得到以下信息:

Hasans-Air:~ h_ajsf$ env
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/_k/x16061cd4rj7sj1z0fkcqghw0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.bX9BTj1wQC/Render
TERM_PROGRAM_VERSION=421.1
TERM_SESSION_ID=C2B37969-41A9-467F-83E4-7E3DAC126B6F
USER=h_ajsf
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.48dHTxJRcg/Listeners
PATH=/usr/local/Cellar/flutter/bin:/Users/h_ajsf/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tools:/tools:/platform-tools:/platform-tools
PWD=/Users/h_ajsf


JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/h_ajsf
LOGNAME=h_ajsf
LC_CTYPE=UTF-8
_=/usr/bin/env
Hasans-Air:~ h_ajsf$ 

当我检查变量时,我得到以下信息:

Hasans-Air:~ h_ajsf$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
Hasans-Air:~ h_ajsf$ /usr/libexec/android_home
-bash: /usr/libexec/android_home: No such file or directory
Hasans-Air:~ h_ajsf$ /usr/libexec/android_sdk_root
-bash: /usr/libexec/android_sdk_root: No such file or directory
Hasans-Air:~ h_ajsf$ 

我的问题是:我犯的错误在哪里,为什么会这样说Android SDK missing command tool,以及如何解决它”?

4

1 回答 1

0
于 2018-11-11T19:58:34.963 回答