Linux命令行安装配置Android SDK

Posted 古月书斋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux命令行安装配置Android SDK相关的知识,希望对你有一定的参考价值。

原文:https://blog.csdn.net/lkl22/article/details/77225096

一、下载安装sdk-tools

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

https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.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命令来查看其帮助

结束!

以上是关于Linux命令行安装配置Android SDK的主要内容,如果未能解决你的问题,请参考以下文章

用命令行方式升级Android SDK

Android sdk manager 无法打开怎么解决

如何用-cmd--命令行进入android sdk的安装目录

如何用-cmd--命令行进入android sdk的安装目录

android SDK 安装配置

如何在 linux 上设置 android SDK 以进行命令行开发?