1. 程式人生 > >Linux命令列安裝配置Android SDK

Linux命令列安裝配置Android SDK

一、下載安裝sdk-tools

Android SDK官網:https://developer.android.com/studio/index.html

wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
unzip sdk-tools-linux-3859397.zip

配置環境變數 vim /etc/profile

export ANDROID_HOME=/developer/android-sdk
export PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH

二、配置網路連線

Force all connections to use http rather than https. 

sdkmanager --update --no_https

三、安裝packages

sdkmanager --list

使用sdkmanager --list命令顯示所有已經安裝的和未安裝的packages,如下:

Installed packages:
  Path                              | Version | Description                       | Location                         
  -------                           | ------- | -------                           | -------                          
  build-tools;24.0.3                | 24.0.3  | Android SDK Build-Tools 24.0.3    | build-tools/24.0.3/              
  build-tools;25.0.3                | 25.0.3  | Android SDK Build-Tools 25.0.3    | build-tools/25.0.3/              
  emulator                          | 26.1.3  | Android Emulator                  | emulator/                        
  extras;android;m2repository       | 47.0.0  | Android Support Repository        | extras/android/m2repository/     
  extras;google;m2repository        | 57      | Google Repository                 | extras/google/m2repository/      
  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                    | 26.0.0  | Android SDK Platform-Tools 26     | platform-tools/                  
  platforms;android-24              | 2       | Android SDK Platform 24           | platforms/android-24/            
  platforms;android-25              | 3       | Android SDK Platform 25           | platforms/android-25/            
  tools                             | 26.0.2  | Android SDK Tools                 | 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   
  cmake;3.6.4111459                 | 3.6.4111459  | CMake 3.6.4111459                
  docs                              | 1            | Documentation for Android SDK    
  emulator                          | 26.1.3       | 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 | 43           | Google Play services

sdkmanager --install

我們可以通過sdkmanager --install命令來進行packages元件的安裝
sdkmanager --install "platforms;android-26"
sdkmanager --install "build-tools;25.0.3" 
sdkmanager --install "extras;google;m2repository"
sdkmanager --install "extras;android;m2repository" 

安裝完成後,Android sdk目錄結構如下所示:

total 32
drwxr-xr-x 4 jenkins root 4096 Aug 15 17:30 build-tools
drwxr-xr-x 7 jenkins root 4096 Aug 14 15:52 emulator
drwxr-xr-x 5 jenkins root 4096 Aug 15 17:31 extras
drwxr-xr-x 2 jenkins root 4096 Aug 14 15:52 licenses
drwxr-xr-x 3 jenkins root 4096 Aug 14 15:52 patcher
drwxr-xr-x 4 jenkins root 4096 Aug 15 17:30 platforms
drwxr-xr-x 5 jenkins root 4096 Aug 14 15:08 platform-tools
drwxr-xr-x 6 jenkins root 4096 Aug 14 15:52 tools

sdkmanager --help

我們可以通過sdkmanager --help命令來檢視其幫助

結束!