Android SDK CUI インストール 手順


*rootで作業想定*

```
$ sudo su -
```

###ディレクトリを作成し、SDKをダウンロードと展開

```
# cd /usr/share/
# mkdir android
# cd android/
# wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
# tar zxvf android-sdk_r24.2-linux.tgz
# chown -R root:root android-sdk-linux/
```

###JAVA_HOMEとパスを設定

```
# export JAVA_HOME=/usr/lib/jvm/java-7-oracle
# export PATH=$PATH:/usr/share/android/android-sdk-linux/tools:/usr/share/android/android-sdk-linux/platform-tools
```

###SDKのアップデートを実行

```
# android update sdk -u
```


######パッケージ一覧を表示

```
# android list sdk -a

Packages available for installation or update: 151
   1- Android SDK Tools, revision 24.3
   2- Android SDK Platform-tools, revision 22
   3- Android SDK Platform-tools, revision 23 rc1
   4- Android SDK Build-tools, revision 23 rc1
   5- Android SDK Build-tools, revision 22.0.1
   6- Android SDK Build-tools, revision 22 (Obsolete)
   7- Android SDK Build-tools, revision 21.1.2
   8- Android SDK Build-tools, revision 21.1.1 (Obsolete)
   9- Android SDK Build-tools, revision 21.1 (Obsolete)
  10- Android SDK Build-tools, revision 21.0.2 (Obsolete)
  11- Android SDK Build-tools, revision 21.0.1 (Obsolete)
  12- Android SDK Build-tools, revision 21 (Obsolete)
  13- Android SDK Build-tools, revision 20
  14- Android SDK Build-tools, revision 19.1
  15- Android SDK Build-tools, revision 19.0.3 (Obsolete)
  16- Android SDK Build-tools, revision 19.0.2 (Obsolete)
  17- Android SDK Build-tools, revision 19.0.1 (Obsolete)
  18- Android SDK Build-tools, revision 19 (Obsolete)
  19- Android SDK Build-tools, revision 18.1.1 (Obsolete)
  20- Android SDK Build-tools, revision 18.1 (Obsolete)
  21- Android SDK Build-tools, revision 18.0.1 (Obsolete)
  22- Android SDK Build-tools, revision 17 (Obsolete)
  23- Documentation for Android 'MNC' Preview SDK, revision 1
  24- SDK Platform Android 5.1.1, API 22, revision 2
  25- SDK Platform Android M Preview, revision 1
  26- SDK Platform Android 5.0.1, API 21, revision 2
  27- SDK Platform Android 4.4W.2, API 20, revision 2
  28- SDK Platform Android 4.4.2, API 19, revision 4
  29- SDK Platform Android 4.3.1, API 18, revision 3
  30- SDK Platform Android 4.2.2, API 17, revision 3
  31- SDK Platform Android 4.1.2, API 16, revision 5
  32- SDK Platform Android 4.0.3, API 15, revision 5
  33- SDK Platform Android 4.0, API 14, revision 4 (Obsolete)
  34- SDK Platform Android 3.2, API 13, revision 1 (Obsolete)
  35- SDK Platform Android 3.1, API 12, revision 3 (Obsolete)
  36- SDK Platform Android 3.0, API 11, revision 2 (Obsolete)
  37- SDK Platform Android 2.3.3, API 10, revision 2
  38- SDK Platform Android 2.3.1, API 9, revision 2 (Obsolete)
  39- SDK Platform Android 2.2, API 8, revision 3
  40- SDK Platform Android 2.1, API 7, revision 3 (Obsolete)
  41- SDK Platform Android 2.0.1, API 6, revision 1 (Obsolete)
  42- SDK Platform Android 2.0, API 5, revision 1 (Obsolete)
  43- SDK Platform Android 1.6, API 4, revision 3 (Obsolete)
  44- SDK Platform Android 1.5, API 3, revision 4 (Obsolete)
  45- SDK Platform Android 1.1, API 2, revision 1 (Obsolete)
  46- Samples for SDK API 22, revision 6
  47- Samples for SDK API MNC Preview, revision 2
  48- Samples for SDK API 21, revision 4
  49- Samples for SDK API 20, revision 3
  50- Samples for SDK API 19, revision 6
  51- Samples for SDK API 18, revision 1
  52- Samples for SDK API 17, revision 1
  53- Samples for SDK API 16, revision 1
  54- Samples for SDK API 15, revision 2
  55- Samples for SDK API 14, revision 2 (Obsolete)
  56- Samples for SDK API 13, revision 1 (Obsolete)
  57- Samples for SDK API 12, revision 1 (Obsolete)
  58- Samples for SDK API 11, revision 1 (Obsolete)
  59- Samples for SDK API 10, revision 1
  60- Samples for SDK API 9, revision 1 (Obsolete)
  61- Samples for SDK API 8, revision 1
  62- Samples for SDK API 7, revision 1 (Obsolete)
  63- Android TV ARM EABI v7a System Image, Android API 22, revision 1
  64- Android TV Intel x86 Atom System Image, Android API 22, revision 1
  65- Android Wear ARM EABI v7a System Image, Android API 22, revision 2
  66- Android Wear Intel x86 Atom System Image, Android API 22, revision 2
  67- ARM EABI v7a System Image, Android API 22, revision 1
  68- Intel x86 Atom_64 System Image, Android API 22, revision 1
  69- Intel x86 Atom System Image, Android API 22, revision 1
  70- Android TV Intel x86 Atom System Image, Android API MNC, revision 1
  71- ARM 64 v8a System Image, Android API MNC, revision 1
  72- ARM EABI v7a System Image, Android API MNC, revision 1
  73- Intel x86 Atom_64 System Image, Android API MNC, revision 1
  74- Intel x86 Atom System Image, Android API MNC, revision 1
  75- MIPS System Image, Android API MNC, revision 1
  76- Android TV ARM EABI v7a System Image, Android API 21, revision 3
  77- Android TV Intel x86 Atom System Image, Android API 21, revision 3
  78- Android Wear ARM EABI v7a System Image, Android API 21, revision 3
  79- Android Wear Intel x86 Atom System Image, Android API 21, revision 3
  80- ARM EABI v7a System Image, Android API 21, revision 3
  81- Intel x86 Atom_64 System Image, Android API 21, revision 3
  82- Intel x86 Atom System Image, Android API 21, revision 3
  83- Android Wear ARM EABI v7a System Image, Android API 20, revision 4
  84- Android Wear Intel x86 Atom System Image, Android API 20, revision 4
  85- ARM EABI v7a System Image, Android API 19, revision 2
  86- Intel x86 Atom System Image, Android API 19, revision 2
  87- ARM EABI v7a System Image, Android API 18, revision 2
  88- Intel x86 Atom System Image, Android API 18, revision 1
  89- ARM EABI v7a System Image, Android API 17, revision 2
  90- Intel x86 Atom System Image, Android API 17, revision 1
  91- MIPS System Image, Android API 17, revision 1
  92- ARM EABI v7a System Image, Android API 16, revision 3
  93- Intel x86 Atom System Image, Android API 16, revision 1
  94- MIPS System Image, Android API 16, revision 4
  95- ARM EABI v7a System Image, Android API 15, revision 2
  96- Intel x86 Atom System Image, Android API 15, revision 1
  97- MIPS System Image, Android API 15, revision 1
  98- ARM EABI v7a System Image, Android API 14, revision 2 (Obsolete)
  99- Intel x86 Atom System Image, Android API 10, revision 2
 100- Google APIs, Android API 22, revision 1
 101- Google APIs, Android API 21, revision 1
 102- Google APIs (x86 System Image), Android API 19, revision 14
 103- Google APIs (ARM System Image), Android API 19, revision 14
 104- Glass Development Kit Preview, Android API 19, revision 11
 105- Google APIs, Android API 18, revision 3
 106- Google APIs, Android API 17, revision 3
 107- Google APIs, Android API 16, revision 3
 108- Google APIs, Android API 15, revision 2
 109- Google APIs, Android API 14, revision 2 (Obsolete)
 110- Google APIs, Android API 13, revision 1 (Obsolete)
 111- Google TV Addon, Android API 13, revision 1 (Obsolete)
 112- Google APIs, Android API 12, revision 1 (Obsolete)
 113- Google TV Addon, Android API 12, revision 2 (Obsolete)
 114- Google APIs, Android API 11, revision 1 (Obsolete)
 115- Google APIs, Android API 10, revision 2
 116- Google APIs, Android API 9, revision 2 (Obsolete)
 117- Google APIs, Android API 8, revision 2
 118- Google APIs, Android API 7, revision 1 (Obsolete)
 119- Google APIs, Android API 6, revision 1 (Obsolete)
 120- Google APIs, Android API 5, revision 1 (Obsolete)
 121- Google APIs, Android API 4, revision 2 (Obsolete)
 122- Google APIs, Android API 3, revision 3 (Obsolete)
 123- Google APIs ARM EABI v7a System Image, Google Inc. API 22, revision 1
 124- Google APIs Intel x86 Atom_64 System Image, Google Inc. API 22, revision 1
 125- Google APIs Intel x86 Atom System Image, Google Inc. API 22, revision 1
 126- Google APIs ARM EABI v7a System Image, Google Inc. API 21, revision 6
 127- Google APIs Intel x86 Atom_64 System Image, Google Inc. API 21, revision 6
 128- Google APIs Intel x86 Atom System Image, Google Inc. API 21, revision 6
 129- Sources for Android SDK, API 22, revision 1
 130- Sources for Android 'MNC' Preview SDK, revision 1
 131- Sources for Android SDK, API 21, revision 1
 132- Sources for Android SDK, API 20, revision 1
 133- Sources for Android SDK, API 19, revision 2
 134- Sources for Android SDK, API 18, revision 1
 135- Sources for Android SDK, API 17, revision 1
 136- Sources for Android SDK, API 16, revision 2
 137- Sources for Android SDK, API 15, revision 2
 138- Sources for Android SDK, API 14, revision 1 (Obsolete)
 139- Android Support Repository, revision 15
 140- Android Support Library, revision 22.2
 141- Google AdMob Ads SDK, revision 11 (Obsolete)
 142- Google Analytics App Tracking SDK, revision 3 (Obsolete)
 143- Google Cloud Messaging for Android Library, revision 3 (Obsolete)
 144- Google Play services for Froyo, revision 12 (Obsolete)
 145- Google Play services, revision 25
 146- Google Repository, revision 19
 147- Google Play APK Expansion Library, revision 3
 148- Google Play Billing Library, revision 5
 149- Google Play Licensing Library, revision 2
 150- Android Auto API Simulators, revision 1
 151- Google Web Driver, revision 2
```


###システムイメージインストール
```
# android list targets

Available Android targets:
----------
id: 2 or "android-10"
     Name: Android 2.3.3
     Type: Platform
     API level: 10
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
 Tag/ABIs : default/armeabi
----------
〜省略〜
----------
id: 10 or "android-22"
     Name: Android 5.1.1
     Type: Platform
     API level: 22
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------

```
最新のPlatformでは、"*Tag/ABIs : no ABIs.*" となっているので、システムイメージを指定してアップデートする必要がある。

######"*67- ARM EABI v7a System Image, Android API 22, revision 1*" をインストール

```
# android update sdk -a -u -t 67
```

###古いビルドツールをインストール

アプリケーションやライブラリで、build.gradleに古いビルドツールを設定され必要としている場合には、ビルドツールを指定してアップデートを行う。

######"*7- Android SDK Build-tools, revision 21.1.2*" をインストール
```
# android update sdk -a -u -t 7
```

###一般ユーザーに実行権を追加
```
# cd android-sdk-linux/tools
# find . -perm -u+x -type f -exec chmod +x {} \;
```