为了在AWS云服务器上实现自动化打包Android APP的APK包,我需要远程命令行环境下安装Android SDK,当然还要用代理或者科学上网,这里简单整理一下过程:

首先,由于墙的原因,Android SDK基本无法直接下,必须使用代理或者国内镜像之类,这里推荐使用上海交大的,参数:

--proxy-host sdk.gdgshanghai.com --proxy-port 8000

以下是具体的安装步骤

1)安装JDK,建议不要使用OpenJDK,使用Oracle的官方版本最佳

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-oracle/bin/java 300
sudo update-alternatives --config java 
sudo vi /etc/environment (添加一行:JAVA_HOME=/usr/lib/jvm/java-8-oracle)

2)安装Android SDK (两种方式,可以直接安装android-studio,不过我用的是亚马逊云的T2.micro主机硬盘很小,为节省空间还是只安装android sdk)

sudo apt-get install lib32z1 lib32ncurses5 lib32stdc++6

wget http://dl.gmirror.org/android/android-sdk_r24.4.1-linux.tgz (从国内镜像下载)
tar -zxvf android-sdk_r24.4.1-linux.tgz

sudo mv ./android-sdk-linux /opt/

3)设置环境变量

echo 'export ANDROID_HOME="/opt/android-sdk-linux"' >> ~/.bashrc
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bashrc
echo 'export JAVA_CMD="/usr/lib/jvm/java-8-oracle/bin/java"' >> ~/.bashrc

4)通过国内镜像下载最新SDK工具

cd /opt/android-sdk-linux/tools

./android -v update sdk -u -s --proxy-host sdk.gdgshanghai.com --proxy-port 8000

(其中,-u参数为不使用GUI方式,同--no-ui参数一致)

5)列出其他安装包

./android -v list sdk --proxy-host sdk.gdgshanghai.com --proxy-port 8000

此命令会列出可更新或者安装的包(非全部)

例如:

Packages available for installation or update: 3
1- SDK Platform Android 2.3.3, API 10, revision 2
2- SDK Platform Android 2.2, API 8, revision 3
3- Samples for SDK API 23, revision 2

根据你需要的编号,输入以下命令进行安装,例如,需要安装3- Samples for SDK API 23, revision 2:

./android update sdk -u --filter 3 --proxy-host sdk.gdgshanghai.com --proxy-port 8000

6)列出所有安装包(-a参数)

./android -v list sdk -a --proxy-host sdk.gdgshanghai.com --proxy-port 8000

此命令会列出所有安装包

例如:

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

然后从这160个中选择你需要的包进行安装:

例如,从160个全列表中安装7- Android SDK Build-tools, revision 22.0.1

./android update sdk -u -a --filter 7 --proxy-host sdk.gdgshanghai.com --proxy-port 8000

Ubuntu下全命令行安装Android SDK的更多相关文章

  1. 04.ubuntu下kvm 命令行安装64位ubuntu报"Couldn't find hvm kernel for Ubuntu tree."的问题

    1.安装ubuntu时使用的virt-install的配置: virt-install \ --name test4 \ --ram 1024 \ --disk path=/data/01_ubunt ...

  2. Ubuntu下用命令行快速打开各类型文件(转)

    nautilus /media/pm/文档/book/system/必读nautilus /media/pm/文档/book/android/ndk 内核/framerwork/android wai ...

  3. mac下使用命令行安装、卸载ipa包、查看日志

    mac下使用命令行安装.卸载ipa包.查看日志 https://www.cnblogs.com/lily1989/p/8383916.html

  4. 打造一个全命令行的Android构建系统

    IDE都是给小白程序员的,大牛级别的程序员一定是命令行控,终端控,你看大牛都是使用vim,emacs 就一切搞定” 这话说的虽然有些绝对,但是也不无道理,做开发这行要想效率高,自动化还真是缺少不了命令 ...

  5. win10下使用命令行安装配置appium环境

    安装列表 安卓sdk目录,即ANDROID_HOME设置 关于sdk的安装配置此处略,参考之前文章<Appium+Java(一) Windows环境搭建篇> node运行环境 appium ...

  6. ubuntu下使用命令行创建一个android项目

    在ubuntu中配置好jdk和android_sdk环境后,可以通过命令行方式创建一个android工程. 具体命令如下: android create project --target <ta ...

  7. Ubuntu下用命令行快速打开各类型文件

    在Ubuntu下,通常用命令行打开文本文件,比如用命令gedit.more.cat.vim.less.但当需要打开其他格式文件时,比如pdf. jpg.mp3格式文件,咱们通常做法是进入到文件所在的目 ...

  8. Ubuntu下SVN命令行递归加入文件夹文件(免去一个一个的加入 --force)

    因为在Linux下一直没有找到好的svn工具(类似于TortiseSVN的).当然eSVN这些也不错,但就是使用上认为还不是很习惯.终于还是选择了svn原始的命令行工具来进行版本号控制操作. 命令行的 ...

  9. Ubuntu 下用命令行快速打开html,mp3等文件

    想用命令行打开网页文件,实现方法如下: 1.Ctrl+Alt+T可以打开shell,F11可以全屏显示,输入以下命令即可打开js17.html,并且指定浏览器,比如指定chrome, google-c ...

随机推荐

  1. Python自动化运维之24、JQuery

    jQuery是一个兼容多浏览器的javascript库,核心理念是write less,do more(写得更少,做得更多).它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, ...

  2. Ruby自学笔记(二)— Ruby的一些基础知识

    Ruby安装好之后,我们就可以来实践Ruby语言了. 以下是一些学习到的简单基础知识: 1. 如何执行Ruby文件? 我们编写的Ruby文件是以rb为后缀名的,例如:XXX.rb.当要执行ruby文件 ...

  3. Google测试精华文章(1) - 测试行为,而非实现

    Your trusty Calculator class is one of your most popular open source projects, with many happy users ...

  4. input placeholder文字垂直居中(Mobile & PC)

    Html5输入框支持placeholder,但是在定义文本框中定义placeholder存在兼容问题 <input type="text" placeholder=" ...

  5. [BZOJ 1068] [SCOI2007] 压缩 【记忆化搜索】

    题目链接:BZOJ - 1068 题目分析 这种记忆化搜索(区间 DP) 之前就做过类似的,也是字符串压缩问题,不过这道题稍微复杂一些. 需要注意如果某一段是 S1S1 重复,那么可以变成 M + S ...

  6. 非正式js语法

    有一种格式化的变种(该变种没有通过JSLint测试)略过了花括号,并将if语句放在同一行中. 这样做的好处是该循环语句变得可读性更强(对于每个拥有属性X的元素,就直接对X进行操作). 这样做的结果是只 ...

  7. Android 安装过程中的问题

    Android  安装过程中的问题 上一篇我说到配置android环境,但是在具体的安装过程中,因为下载的软件或者方法不同,导致没有正确的结果,如果有一些错误的时候,可以试一试关闭eclipse软件, ...

  8. 【HDOJ】4704 Sum

    数学题.f(n) = 2^(n-1) mod (1e9+7). #include <cstdio> #define MAXN 100005 char buf[MAXN]; __int64 ...

  9. [Java] Map / HashMap - 源代码学习笔记

    Map 1. 用于关联 key 和 value 的对象,其中 key 与 key 之间不能重复. 2. 是一个接口,用来代替 Java 早期版本中的 Dictionary 抽象类. 3. 提供三种不同 ...

  10. 简单的Goto运算演示程序

    /* * 该程序用于计算某个项集的Goto集 * RexfieldVon * 2013年8月11日2:34:50 */ #include <stdio.h> #include <st ...