brew cask 安装 android-sdk

brew cask install android-sdk

我在 Mac OS X 上安装 android sdk (brew cask install android-idk) 时遇到问题。 我试图为 nativescript 安装它。我读过有同样问题的人,但我找不到可行的解决方案。 我尝试更改 java 路径,也许它会导致问题。

这是我得到的错误:

==> Caveats
We will install android-sdk-tools, platform-tools, and build-tools for you.
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'

This operation may take up to 10 minutes depending on your internet connection.
Please, be patient.

==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip
Already downloaded: /Users/jhon/Library/Caches/Homebrew/Cask/android-sdk--3859397,26.0.1.zip
==> Verifying checksum for Cask android-sdk
==> Installing Cask android-sdk
==> Warning: Failed to download any source lists!
==> Warning: java.nio.file.NoSuchFileException: /Users/jhon/.android/cache/sdkbin-1_b735609c-repository2-1_xml
==> Warning: Failed to find package tools
Error: Command failed to execute!

==> Failed command:
/usr/local/Caskroom/android-sdk/3859397,26.0.1/tools/bin/sdkmanager tools platform-tools build-tools;26.0.1

==> Standard Output of failed command:


==> Standard Error of failed command:
jhon-MacBook-Pro-8:appNativescript jhon$ brew cask install android-idk --verbose --debug
Error: Cask 'android-idk' is unavailable: No Cask with this name exists.
Error: Install incomplete.
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/install.rb:13:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb:35:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:97:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:167:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:131:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:8:in `cask'
jhon-MacBook-Pro-8:appNativescript jhon$ brew cask install android-sdk
==> Caveats
We will install android-sdk-tools, platform-tools, and build-tools for you.
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'

This operation may take up to 10 minutes depending on your internet connection.
Please, be patient.

==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip
Already downloaded: /Users/jhon/Library/Caches/Homebrew/Cask/android-sdk--3859397,26.0.1.zip
==> Verifying checksum for Cask android-sdk
==> Installing Cask android-sdk
==> Warning: Failed to download any source lists!
==> Warning: java.nio.file.NoSuchFileException: /Users/jhon/.android/cache/sdkbin-1_b735609c-repository2-1_xml
==> Warning: Failed to find package tools
Error: Command failed to execute!

==> Failed command:
/usr/local/Caskroom/android-sdk/3859397,26.0.1/tools/bin/sdkmanager tools platform-tools build-tools;26.0.1

==> Standard Output of failed command:


==> Standard Error of failed command:
Warning: Failed to download any source lists!
Warning: java.nio.file.NoSuchFileException: /Users/jhon/.android/cache/sdkbin-1_b735609c-repository2-1_xml
Warning: Failed to find package tools


==> Exit status of failed command:
#<Process::Status: pid 35477 exit 1>
Error: Install incomplete.
jhon-MacBook-Pro-8:appNatives

这是文档所说的,您可以试一试 -

解决方案 1 -

安装 Android 开发的依赖项。

安装JDK 8或更高版本的稳定官方版本。

  • 转到 Java SE 下载并单击 JDK 的下载。
  • 在 Java SE 开发工具包部分,接受许可协议并单击下载 link for Mac macOS。
  • 等待下载完成并安装 JDK.
  • 设置JAVA_HOME系统环境变量。
  • 导出 JAVA_HOME=$(/usr/libexec/java_home) 安装 Android SDK。

运行下面的命令在Terminal:

  • brew cask install android-sdk

接下来,运行以下命令设置ANDROID_HOME系统环境变量:

  • export ANDROID_HOME=/usr/local/share/android-sdk

注意:这是包含工具和平台工具目录的目录。 此外,安装 Android SDK Platform 25、Android SDK Build-Tools 25.0.2 或更高版本、Android Support Repository、Google Repository 和任何其他 SDK 的所有软件包你可能需要。您也可以使用以下命令,这将安装所有必需的包。

  • $ANDROID_HOME/tools/bin/sdkmanager

"tools" "platform-tools" "platforms;android-25" "build-tools;25.0.2" "extras;android;m2repository" "extras;google;m2repository" 按照此处的文章设置 Android 模拟器 (AVD)

解决方案 2

下载 Android Studio 并更新 API 级别并支持 repos 就是这样 - 对我来说一直有效 Android SDK