14
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android Studioを入れずにAndroid SDKをインストールする方法(Mac)

Last updated at Posted at 2018-04-05

はじめに

Android StudioをインストールするとAndroid SDKも同時にインストールされます。
しかし、私はIntelliJ IDEAを使いたいため、Android StudioをインストールせずにAndroid SDK Toolsからコマンドラインでインストールすることにします。

SDKMANを使ってインストールできたら便利だと思ったのですが、2018/04/05現在ではできませんでした。

環境

  • OS:macOS High Sierra 10.13.1
  • Android SDK Tools:26.0.1

Android SDK Toolsのインストール

Android Studioの公式サイトからダウンロードします。
「コマンドライン ツールのみ入手する」から対象プラットフォームの「SDK ツールパッケージ」をクリックします。
https://developer.android.com/studio/index.html

スクリーンショット_2018-04-05_21_56_26.jpg

「上記の利用規約を読み、同意します。」チェックをONにし、「SDK-TOOLS-DARWIN-3859397.ZIP ダウンロード」をクリックします。

スクリーンショット_2018-04-05_21_58_03.jpg

ダウンロードには時間がかかります。

スクリーンショット 2018-04-05 22.06.15.png

ダウンロードが完了したら解凍してスペースが含まれていないパスに配置します。
私は /opt に配置しました。
/opt は管理者権限が必要なため、 /usr/local/optandroid-sdk フォルダを作成してその直下に配置しました。
配置先のフォルダに権限が不足していると、Android SDKのインストール時に Warning: Failed to read or create install properties file. エラーが出るので注意してください。

Android SDK Toolsのパスを通すため、 .bash_profile に以下を追記します。

.bash_profile
# Android SDK Tools
if [ -d "/usr/local/opt/android-sdk/tools/bin" ]; then
  export PATH=$PATH:/usr/local/opt/android-sdk/tools/bin
fi

これでAndroid SDK Toolsのインストールは完了です。

Android SDKのインストール

# インストールできるSDKの一覧を表示する
$ sdkmanager --list
Warning: File /Users/{ユーザー名}/.android/repositories.cfg could not be loaded.
Installed packages:
  Path    | Version | Description              | Location
  ------- | ------- | -------                  | -------
  tools   | 26.0.1  | Android SDK Tools 26.0.1 | tools/

Available Packages:
  Path                              | Version      | Description
  -------                           | -------      | -------
  add-ons;addon-g..._apis-google-15 | 3            | Google APIs
  add-ons;addon-g..._apis-google-16 | 4            | Google APIs
  add-ons;addon-g..._apis-google-17 | 4            | Google APIs
  add-ons;addon-g..._apis-google-18 | 4            | Google APIs
  add-ons;addon-g..._apis-google-19 | 20           | Google APIs
  add-ons;addon-g..._apis-google-21 | 1            | Google APIs
  add-ons;addon-g..._apis-google-22 | 1            | Google APIs
  add-ons;addon-g..._apis-google-23 | 1            | Google APIs
  add-ons;addon-g..._apis-google-24 | 1            | Google APIs
  add-ons;addon-g...e_gdk-google-19 | 11           | Glass Development Kit Preview
  build-tools;19.1.0                | 19.1.0       | Android SDK Build-Tools 19.1
  build-tools;20.0.0                | 20.0.0       | Android SDK Build-Tools 20
  build-tools;21.1.2                | 21.1.2       | Android SDK Build-Tools 21.1.2
  build-tools;22.0.1                | 22.0.1       | Android SDK Build-Tools 22.0.1
  build-tools;23.0.1                | 23.0.1       | Android SDK Build-Tools 23.0.1
  build-tools;23.0.2                | 23.0.2       | Android SDK Build-Tools 23.0.2
  build-tools;23.0.3                | 23.0.3       | Android SDK Build-Tools 23.0.3
  build-tools;24.0.0                | 24.0.0       | Android SDK Build-Tools 24
  build-tools;24.0.1                | 24.0.1       | Android SDK Build-Tools 24.0.1
  build-tools;24.0.2                | 24.0.2       | Android SDK Build-Tools 24.0.2
  build-tools;24.0.3                | 24.0.3       | Android SDK Build-Tools 24.0.3
  build-tools;25.0.0                | 25.0.0       | Android SDK Build-Tools 25
  build-tools;25.0.1                | 25.0.1       | Android SDK Build-Tools 25.0.1
  build-tools;25.0.2                | 25.0.2       | Android SDK Build-Tools 25.0.2
  build-tools;25.0.3                | 25.0.3       | Android SDK Build-Tools 25.0.3
  build-tools;26.0.0                | 26.0.0       | Android SDK Build-Tools 26
  build-tools;26.0.1                | 26.0.1       | Android SDK Build-Tools 26.0.1
  build-tools;26.0.2                | 26.0.2       | Android SDK Build-Tools 26.0.2
  build-tools;26.0.3                | 26.0.3       | Android SDK Build-Tools 26.0.3
  build-tools;27.0.0                | 27.0.0       | Android SDK Build-Tools 27
  build-tools;27.0.1                | 27.0.1       | Android SDK Build-Tools 27.0.1
  build-tools;27.0.2                | 27.0.2       | Android SDK Build-Tools 27.0.2
  build-tools;27.0.3                | 27.0.3       | Android SDK Build-Tools 27.0.3
  build-tools;28.0.0-rc1            | 28.0.0 rc1   | Android SDK Build-Tools 28-rc1
  cmake;3.6.4111459                 | 3.6.4111459  | CMake 3.6.4111459
  docs                              | 1            | Documentation for Android SDK
  emulator                          | 27.1.12      | Android Emulator
  extras;android;gapid;1            | 1.0.3        | GPU Debugging tools
  extras;android;gapid;3            | 3.1.0        | GPU Debugging tools
  extras;android;m2repository       | 47.0.0       | Android Support Repository
  extras;google;auto                | 1.1          | Android Auto Desktop Head Unit...
  extras;google;g...e_play_services | 48           | Google Play services
  extras;google;instantapps         | 1.1.0        | Instant Apps Development SDK
  extras;google;m2repository        | 58           | Google Repository
  extras;google;m...t_apk_expansion | 1            | Google Play APK Expansion library
  extras;google;market_licensing    | 1            | Google Play Licensing Library
  extras;google;simulators          | 1            | Android Auto API Simulators
  extras;google;webdriver           | 2            | Google Web Driver
  extras;intel;Ha...ecution_Manager | 6.2.1        | Intel x86 Emulator Accelerator...
  extras;m2reposi...ut-solver;1.0.0 | 1            | Solver for ConstraintLayout 1.0.0
  extras;m2reposi...er;1.0.0-alpha2 | 1            | com.android.support.constraint...
  extras;m2reposi...er;1.0.0-alpha3 | 1            | com.android.support.constraint...
  extras;m2reposi...er;1.0.0-alpha4 | 1            | com.android.support.constraint...
  extras;m2reposi...er;1.0.0-alpha5 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...er;1.0.0-alpha6 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...er;1.0.0-alpha7 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...er;1.0.0-alpha8 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...er;1.0.0-alpha9 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ver;1.0.0-beta1 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ver;1.0.0-beta2 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ver;1.0.0-beta3 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ver;1.0.0-beta4 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ver;1.0.0-beta5 | 1            | Solver for ConstraintLayout 1....
  extras;m2reposi...ut-solver;1.0.1 | 1            | Solver for ConstraintLayout 1.0.1
  extras;m2reposi...ut-solver;1.0.2 | 1            | Solver for ConstraintLayout 1.0.2
  extras;m2reposi...nt-layout;1.0.0 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...ut;1.0.0-alpha2 | 1            | com.android.support.constraint...
  extras;m2reposi...ut;1.0.0-alpha3 | 1            | com.android.support.constraint...
  extras;m2reposi...ut;1.0.0-alpha4 | 1            | com.android.support.constraint...
  extras;m2reposi...ut;1.0.0-alpha5 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...ut;1.0.0-alpha6 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...ut;1.0.0-alpha7 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...ut;1.0.0-alpha8 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...ut;1.0.0-alpha9 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...out;1.0.0-beta1 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...out;1.0.0-beta2 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...out;1.0.0-beta3 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...out;1.0.0-beta4 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...out;1.0.0-beta5 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...nt-layout;1.0.1 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...nt-layout;1.0.2 | 1            | ConstraintLayout for Android 1...
  lldb;2.0                          | 2.0.2558144  | LLDB 2.0
  lldb;2.1                          | 2.1.2852477  | LLDB 2.1
  lldb;2.2                          | 2.2.3271982  | LLDB 2.2
  lldb;2.3                          | 2.3.3614996  | LLDB 2.3
  lldb;3.0                          | 3.0.4213617  | LLDB 3.0
  lldb;3.1                          | 3.1.4508709  | LLDB 3.1
  ndk-bundle                        | 16.1.4479499 | NDK
  patcher;v4                        | 1            | SDK Patch Applier v4
  platform-tools                    | 27.0.1       | Android SDK Platform-Tools
  platforms;android-10              | 2            | Android SDK Platform 10
  platforms;android-11              | 2            | Android SDK Platform 11
  platforms;android-12              | 3            | Android SDK Platform 12
  platforms;android-13              | 1            | Android SDK Platform 13
  platforms;android-14              | 4            | Android SDK Platform 14
  platforms;android-15              | 5            | Android SDK Platform 15
  platforms;android-16              | 5            | Android SDK Platform 16
  platforms;android-17              | 3            | Android SDK Platform 17
  platforms;android-18              | 3            | Android SDK Platform 18
  platforms;android-19              | 4            | Android SDK Platform 19
  platforms;android-20              | 2            | Android SDK Platform 20
  platforms;android-21              | 2            | Android SDK Platform 21
  platforms;android-22              | 2            | Android SDK Platform 22
  platforms;android-23              | 3            | Android SDK Platform 23
  platforms;android-24              | 2            | Android SDK Platform 24
  platforms;android-25              | 3            | Android SDK Platform 25
  platforms;android-26              | 2            | Android SDK Platform 26
  platforms;android-27              | 1            | Android SDK Platform 27
  platforms;android-7               | 3            | Android SDK Platform 7
  platforms;android-8               | 3            | Android SDK Platform 8
  platforms;android-9               | 2            | Android SDK Platform 9
  platforms;android-P               | 2            | Android SDK Platform P
  sources;android-15                | 2            | Sources for Android 15
  sources;android-16                | 2            | Sources for Android 16
  sources;android-17                | 1            | Sources for Android 17
  sources;android-18                | 1            | Sources for Android 18
  sources;android-19                | 2            | Sources for Android 19
  sources;android-20                | 1            | Sources for Android 20
  sources;android-21                | 1            | Sources for Android 21
  sources;android-22                | 1            | Sources for Android 22
  sources;android-23                | 1            | Sources for Android 23
  sources;android-24                | 1            | Sources for Android 24
  sources;android-25                | 1            | Sources for Android 25
  sources;android-26                | 1            | Sources for Android 26
  sources;android-27                | 1            | Sources for Android 27
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  system-images;a...-10;default;x86 | 4            | Intel x86 Atom System Image
  system-images;a...pis;armeabi-v7a | 5            | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...ult;armeabi-v7a | 2            | ARM EABI v7a System Image
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  system-images;a...15;default;mips | 1            | MIPS System Image
  system-images;a...-15;default;x86 | 4            | Intel x86 Atom System Image
  system-images;a...pis;armeabi-v7a | 5            | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  system-images;a...16;default;mips | 1            | MIPS System Image
  system-images;a...-16;default;x86 | 5            | Intel x86 Atom System Image
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...ult;armeabi-v7a | 5            | ARM EABI v7a System Image
  system-images;a...17;default;mips | 1            | MIPS System Image
  system-images;a...-17;default;x86 | 3            | Intel x86 Atom System Image
  system-images;a...pis;armeabi-v7a | 5            | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  system-images;a...-18;default;x86 | 3            | Intel x86 Atom System Image
  system-images;a...pis;armeabi-v7a | 5            | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...ult;armeabi-v7a | 5            | ARM EABI v7a System Image
  system-images;a...-19;default;x86 | 6            | Intel x86 Atom System Image
  system-images;a...pis;armeabi-v7a | 34           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 34           | Google APIs Intel x86 Atom Sys...
  system-images;a...-tv;armeabi-v7a | 3            | Android TV ARM EABI v7a System...
  system-images;a...;android-tv;x86 | 3            | Android TV Intel x86 Atom Syst...
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  system-images;a...-21;default;x86 | 5            | Intel x86 Atom System Image
  system-images;a...;default;x86_64 | 5            | Intel x86 Atom_64 System Image
  system-images;a...pis;armeabi-v7a | 26           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 26           | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 26           | Google APIs Intel x86 Atom_64 ...
  system-images;a...-tv;armeabi-v7a | 1            | Android TV ARM EABI v7a System...
  system-images;a...;android-tv;x86 | 3            | Android TV Intel x86 Atom Syst...
  system-images;a...ult;armeabi-v7a | 2            | ARM EABI v7a System Image
  system-images;a...-22;default;x86 | 6            | Intel x86 Atom System Image
  system-images;a...;default;x86_64 | 6            | Intel x86 Atom_64 System Image
  system-images;a...pis;armeabi-v7a | 20           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 20           | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 20           | Google APIs Intel x86 Atom_64 ...
  system-images;a...-tv;armeabi-v7a | 12           | Android TV ARM EABI v7a System...
  system-images;a...;android-tv;x86 | 15           | Android TV Intel x86 Atom Syst...
  system-images;a...ear;armeabi-v7a | 6            | Android Wear ARM EABI v7a Syst...
  system-images;a...ndroid-wear;x86 | 6            | Android Wear Intel x86 Atom Sy...
  system-images;a...-23;default;x86 | 10           | Intel x86 Atom System Image
  system-images;a...;default;x86_64 | 10           | Intel x86 Atom_64 System Image
  system-images;a...pis;armeabi-v7a | 27           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 27           | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 27           | Google APIs Intel x86 Atom_64 ...
  system-images;a...;android-tv;x86 | 16           | Android TV Intel x86 Atom Syst...
  system-images;a...fault;arm64-v8a | 7            | ARM 64 v8a System Image
  system-images;a...ult;armeabi-v7a | 7            | ARM EABI v7a System Image
  system-images;a...-24;default;x86 | 8            | Intel x86 Atom System Image
  system-images;a...;default;x86_64 | 8            | Intel x86 Atom_64 System Image
  system-images;a..._apis;arm64-v8a | 21           | Google APIs ARM 64 v8a System ...
  system-images;a...pis;armeabi-v7a | 21           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 21           | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 21           | Google APIs Intel x86 Atom_64 ...
  system-images;a...s_playstore;x86 | 19           | Google Play Intel x86 Atom Sys...
  system-images;a...;android-tv;x86 | 10           | Android TV Intel x86 Atom Syst...
  system-images;a...-cn;armeabi-v7a | 4            | China version of Android Wear ...
  system-images;a...oid-wear-cn;x86 | 4            | China version of Android Wear ...
  system-images;a...ear;armeabi-v7a | 3            | Android Wear ARM EABI v7a Syst...
  system-images;a...ndroid-wear;x86 | 3            | Android Wear Intel x86 Atom Sy...
  system-images;a..._apis;arm64-v8a | 12           | Google APIs ARM 64 v8a System ...
  system-images;a...pis;armeabi-v7a | 12           | Google APIs ARM EABI v7a Syste...
  system-images;a...google_apis;x86 | 12           | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 12           | Google APIs Intel x86 Atom_64 ...
  system-images;a...s_playstore;x86 | 9            | Google Play Intel x86 Atom Sys...
  system-images;a...;android-tv;x86 | 8            | Android TV Intel x86 Atom Syst...
  system-images;a...oid-wear-cn;x86 | 4            | China version of Android Wear ...
  system-images;a...ndroid-wear;x86 | 4            | Android Wear Intel x86 Atom Sy...
  system-images;a...google_apis;x86 | 9            | Google APIs Intel x86 Atom Sys...
  system-images;a...gle_apis;x86_64 | 9            | Google APIs Intel x86 Atom_64 ...
  system-images;a...s_playstore;x86 | 7            | Google Play Intel x86 Atom Sys...
  system-images;a...;android-tv;x86 | 3            | Android TV Intel x86 Atom Syst...
  system-images;a...google_apis;x86 | 5            | Google APIs Intel x86 Atom Sys...
  system-images;a...s_playstore;x86 | 3            | Google Play Intel x86 Atom Sys...
  system-images;a...;android-tv;x86 | 1            | Android TV Intel x86 Atom Syst...
  system-images;a...oid-wear-cn;x86 | 1            | China version of Wear OS Intel...
  system-images;a...ndroid-wear;x86 | 1            | Wear OS Intel x86 Atom System ...
  system-images;a...google_apis;x86 | 1            | Google APIs Intel x86 Atom Sys...
  system-images;a...s_playstore;x86 | 1            | Google Play Intel x86 Atom Sys...
  tools                             | 26.1.1       | Android SDK Tools

Available Updates:
  ID      | Installed | Available
  ------- | -------   | -------
  tools   | 26.0.1    | 26.1.1
done

Warning: File /Users/{ユーザー名}/.android/repositories.cfg could not be loaded. 警告が出力されています。
以下の記事の通りに設定ファイルを作成すれば警告が出なくなります。
https://stackoverflow.com/questions/43433542/stuck-at-android-repositories-cfg-could-not-be-loaded

$ touch ~/.android/repositories.cfg

以下を参考に、必要なSDKをインストールします。
https://developer.android.com/studio/intro/update.html

# SDK名はダブルコーテーションで括る必要がある
# Accept? (y/N):  は「y」を入力する
$ sdkmanager "build-tools;28.0.3"
$ sdkmanager "platform-tools"
$ sdkmanager "tools"
$ sdkmanager "extras;android;m2repository" # Support Repository
$ sdkmanager "extras;google;m2repository" # Google Repository
$ sdkmanager "extras;google;google_play_services" # Google Play Services
$ sdkmanager "sources;android-14"
$ sdkmanager "sources;android-15"
$ sdkmanager "sources;android-16"
$ sdkmanager "sources;android-17"
$ sdkmanager "sources;android-18"
$ sdkmanager "sources;android-19"
$ sdkmanager "sources;android-20"
$ sdkmanager "sources;android-21"
$ sdkmanager "sources;android-22"
$ sdkmanager "sources;android-23"
$ sdkmanager "sources;android-24"
$ sdkmanager "sources;android-25"
$ sdkmanager "sources;android-26"
$ sdkmanager "sources;android-27"
$ sdkmanager "sources;android-28"
$ sdkmanager "platforms;android-14"
$ sdkmanager "platforms;android-15"
$ sdkmanager "platforms;android-16"
$ sdkmanager "platforms;android-17"
$ sdkmanager "platforms;android-18"
$ sdkmanager "platforms;android-19"
$ sdkmanager "platforms;android-20"
$ sdkmanager "platforms;android-21"
$ sdkmanager "platforms;android-22"
$ sdkmanager "platforms;android-23"
$ sdkmanager "platforms;android-24"
$ sdkmanager "platforms;android-25"
$ sdkmanager "platforms;android-26"
$ sdkmanager "platforms;android-27"
$ sdkmanager "emulator"

プログレスバーなどが表示されないので、途中で中止しないよう注意してください。
時間がかかりますが、「done」と出力されるまではインストール中です。

$ sdkmanager "platform-tools"
done

インストールされたか確認します。

$ sdkmanager --list
Installed packages:
  Path                              | Version | Description                       | Location
  -------                           | ------- | -------                           | -------
  build-tools;27.0.3                | 27.0.3  | Android SDK Build-Tools 27.0.3    | build-tools/27.0.3/
  emulator                          | 27.1.12 | Android Emulator                  | emulator/
  extras;intel;Ha...ecution_Manager | 6.2.1   | Intel x86 Emulator Accelerator... | extras/intel/Ha...cution_Manager/
  extras;m2reposi...ut-solver;1.0.2 | 1       | Solver for ConstraintLayout 1.0.2 | extras/m2reposi...t-solver/1.0.2/
  extras;m2reposi...nt-layout;1.0.2 | 1       | ConstraintLayout for Android 1... | extras/m2reposi...t-layout/1.0.2/
  patcher;v4                        | 1       | SDK Patch Applier v4              | patcher/v4/
  platform-tools                    | 27.0.1  | Android SDK Platform-Tools        | platform-tools/
  platforms;android-27              | 1       | Android SDK Platform 27           | platforms/android-27/
  tools                             | 26.0.1  | Android SDK Tools 26.0.1          | tools/

Available Packages:
…

インストールに成功しています。
「emulator」をインストールすると下の4つもインストールされるようです。

おわりに

Android SDKをインストールすることができました。
次は それをIntelliJ IDEAに適用する方法 を紹介します。

参考リンク

14
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?