红联Linux门户
Linux帮助

Linux下配置Android SDK

发布时间:2014-11-11 10:24:06来源:linux网站作者:catoop

该文章介绍下如何在Linux下配置Android SDK。


一、下载android sdk

下载SDK,下载地址点击http://developer.android.com/sdk/index.html,选择Linux(i386)。因为SDK只有32位的,如果装的是64位系统,则要安装ia32-libs,运行32位程序。安装命令:sudo apt-get install ia32-libs(在Ubuntu中的命令)。下载完成后解压,在终端进入到SDK的根目录,然后执行:tools/android update sdk –no-ui即可开始和Windows里面一样的更新。

[root@app-server1 tools]# android update sdk --no-ui 
Refresh Sources: 
Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml 
Validate XML 
Parse XML 
Fetched Add-ons List successfully 
Refresh Sources 
Fetching URL: https://dl-ssl.google.com/android/repository/repository-6.xml 
Validate XML: https://dl-ssl.google.com/android/repository/repository-6.xml 
Parse XML:    https://dl-ssl.google.com/android/repository/repository-6.xml 
Fetching URL: https://dl-ssl.google.com/android/repository/addon.xml 
Validate XML: https://dl-ssl.google.com/android/repository/addon.xml 
Parse XML:    https://dl-ssl.google.com/android/repository/addon.xml 
Fetching URL: http://dl.htcdev.com/sdk/addon.xml 
Validate XML: http://dl.htcdev.com/sdk/addon.xml 
Parse XML:    http://dl.htcdev.com/sdk/addon.xml 
Fetching URL: http://software.intel.com/sites/landingpage/android/addon.xml 
Validate XML: http://software.intel.com/sites/landingpage/android/addon.xml 
Parse XML:    http://software.intel.com/sites/landingpage/android/addon.xml 
Fetching URL: http://www.echobykyocera.com/download/echo_repository.xml 
Validate XML: http://www.echobykyocera.com/download/echo_repository.xml 
Parse XML:    http://www.echobykyocera.com/download/echo_repository.xml 
Fetching URL: http://developer.lgmobile.com/sdk/android/repository.xml 
Validate XML: http://developer.lgmobile.com/sdk/android/repository.xml 
Parse XML:    http://developer.lgmobile.com/sdk/android/repository.xml 
Fetching URL: http://android-sdk-addons.motodevupdate.com/addons.xml 
Validate XML: http://android-sdk-addons.motodevupdate.com/addons.xml 
Parse XML:    http://android-sdk-addons.motodevupdate.com/addons.xml 
Fetching URL: http://innovator.samsungmobile.com/android/repository/repository.xml 
Validate XML: http://innovator.samsungmobile.com/android/repository/repository.xml 
Parse XML:    http://innovator.samsungmobile.com/android/repository/repository.xml 
Fetching URL: http://developer.sonymobile.com/edk/android/repository.xml 
Validate XML: http://developer.sonymobile.com/edk/android/repository.xml 
Parse XML:    http://developer.sonymobile.com/edk/android/repository.xml 
Installing Archives: 
Preparing to install archives 
Downloading Android SDK Platform-tools, revision 11 
Installing Android SDK Platform-tools, revision 11 
Stopping ADB server failed (code -1). 
Installed Android SDK Platform-tools, revision 1199%) 
Downloading Documentation for Android SDK, API 15, revision 2 
Installing Documentation for Android SDK, API 15, revision 2 
Installed Documentation for Android SDK, API 15, revision 297%) 
Downloading SDK Platform Android 4.0.3, API 15, revision 3 
Installing SDK Platform Android 4.0.3, API 15, revision 3 
Installed SDK Platform Android 4.0.3, API 15, revision 396%) 
Downloading SDK Platform Android 4.0, API 14, revision 3 
Installing SDK Platform Android 4.0, API 14, revision 3 
Installed SDK Platform Android 4.0, API 14, revision 396%) 
Downloading SDK Platform Android 3.2, API 13, revision 1 
Installing SDK Platform Android 3.2, API 13, revision 1 
Installed SDK Platform Android 3.2, API 13, revision 198%) 
Downloading SDK Platform Android 3.1, API 12, revision 3 
Installing SDK Platform Android 3.1, API 12, revision 3 
Installed SDK Platform Android 3.1, API 12, revision 398%) 
Downloading SDK Platform Android 3.0, API 11, revision 2 
Installing SDK Platform Android 3.0, API 11, revision 2 
Installed SDK Platform Android 3.0, API 11, revision 298%) 
Downloading SDK Platform Android 2.3.3, API 10, revision 2 
Installing SDK Platform Android 2.3.3, API 10, revision 2 
Installed SDK Platform Android 2.3.3, API 10, revision 298%) 
Downloading SDK Platform Android 2.2, API 8, revision 3 
Installing SDK Platform Android 2.2, API 8, revision 3 
Installed SDK Platform Android 2.2, API 8, revision 399%) 
Downloading SDK Platform Android 2.1, API 7, revision 3 
Installing SDK Platform Android 2.1, API 7, revision 3 
Installed SDK Platform Android 2.1, API 7, revision 399%) 
Downloading SDK Platform Android 1.6, API 4, revision 3 
Installing SDK Platform Android 1.6, API 4, revision 3 
Installed SDK Platform Android 1.6, API 4, revision 399%) 
Downloading SDK Platform Android 1.5, API 3, revision 4 
Installing SDK Platform Android 1.5, API 3, revision 4 
Installed SDK Platform Android 1.5, API 3, revision 499%) 
Downloading Samples for SDK API 15, revision 2 
Installing Samples for SDK API 15, revision 2 
Installed Samples for SDK API 15, revision 296%) 
Downloading Samples for SDK API 14, revision 2 
Installing Samples for SDK API 14, revision 2 
Installed Samples for SDK API 14, revision 296%) 
Downloading Samples for SDK API 13, revision 1 
Installing Samples for SDK API 13, revision 1 
Installed Samples for SDK API 13, revision 195%) 
Downloading Samples for SDK API 12, revision 1 
Installing Samples for SDK API 12, revision 1 
Installed Samples for SDK API 12, revision 195%) 
Downloading Samples for SDK API 11, revision 1 
Installing Samples for SDK API 11, revision 1 
Installed Samples for SDK API 11, revision 195%) 
Downloading Samples for SDK API 10, revision 1 
Installing Samples for SDK API 10, revision 1 
Installed Samples for SDK API 10, revision 195%) 
Downloading Samples for SDK API 8, revision 1 
Installing Samples for SDK API 8, revision 1 
Installed Samples for SDK API 8, revision 196%) 
Downloading Samples for SDK API 7, revision 1 
Installing Samples for SDK API 7, revision 1 
Installed Samples for SDK API 7, revision 196%) 
Downloading Android Support, revision 8 
Installing Android Support, revision 8 
Installed Android Support, revision 891%) 
Downloading Google AdMob Ads SDK, revision 6 
Installing Google AdMob Ads SDK, revision 6 
Installed Google AdMob Ads SDK, revision 694%) 
Downloading Google Analytics SDK, revision 2 
Installing Google Analytics SDK, revision 2 
Installed Google Analytics SDK, revision 292%) 
Downloading Google Play APK Expansion Library, revision 1 
Installing Google Play APK Expansion Library, revision 1 
Installed Google Play APK Expansion Library, revision 178%) 
Downloading Google Play Billing Library, revision 2 
Installing Google Play Billing Library, revision 2 
Installed Google Play Billing Library, revision 284%) 
Downloading Google Play Licensing Library, revision 2 
Installing Google Play Licensing Library, revision 2 
Installed Google Play Licensing Library, revision 272%) 
Downloading Google Web Driver, revision 2 
Installing Google Web Driver, revision 2 
Installed Google Web Driver, revision 299%) 
Downloading Android SDK Tools, revision 19 
Installing Android SDK Tools, revision 19 
Installed Android SDK Tools, revision 1999%) 
Downloading ARM EABI v7a System Image, Android API 15, revision 2 
Installing ARM EABI v7a System Image, Android API 15, revision 2 
Installed ARM EABI v7a System Image, Android API 15, revision 299%) 
Downloading Intel x86 Atom System Image, Android API 15, revision 1 
………(下面省略)……… 

上面更新的过程中一些特殊的SDK是需要用户名和密码的,如:摩托罗拉和HTC。

我们到这些官网注册一下即可,摩托罗拉和HTC的网址:

注册官网:http://htcdev.com/ 这个是HTC的;具体的注册过程我就不多说了,要是看不懂的大家直接在线翻译一下就可以了

另外一个:https://developer.motorola.com/ 这个是MOTO的,也是一样的需要注册一下,方法同上面的HTC的一样。


二、配置环境变量

更新完成后配置环境变量。使用命令 vi /etc/profile 编辑文件profile,然后在下面增加下面内容:

export Android_HOME=/opt/softwaretools/android-sdk-linux

export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH

/opt/softwaretools/android-sdk-linux为SDK的根目录。

这个配置之后,以后要执行android里面的命令,就不是需要进到这个目录,直接可以在终端里面输入。

修改完成后,使用命令 :wq! 保存关闭文件,再执行命令 source /etc/profile 使配置生效一下。

在终端输入:android,如果Android SDK Manager窗口出来了,就证明环境配置成功。