linux下centos安装android sdk最新全面教程【可行】
1.此教程解决了当你配置完android sdk的环境变量以后,可能在命令中打入adb还是提示错误。现在给大家提供最新解决方法,此方法同时可以解决最新的centos 6.5版本
2.本教程支持最新java8,并与此为例。
工具/原料
-
java8下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
-
注:ubuntu选tar.gz后缀;centos选rmp后缀
-
android sdk(内包括eclipse)下载地址:http://developer.android.com/sdk/index.html
-
注:下载SDK时候,linux点DOWNLOAD FOR OTHER PLATFORMS跟据自己系统类型选择Linux 64-bit或是Linux 32-bit的下载
方法/步骤
-
卸载旧版JDK
1.命令中打入$ java -version查看版本
java version "1.7.0_19"OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
2.查看OpenJDK的安装包
$命令中打入 rpm -qa |grep javatzdata-java-2013b-1.el6.noarchjava-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
3.卸载
$ su
密码: $ rpm -e --nodeps java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
$ rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64 $ rpm -e --nodeps tzdata-java-2013b-1.el6.noarch
4.安装JDK
下载JDK1.8.0_05
输入$ cd /jdk1.8.0_0所在目录
$ rpm -ivh jdk-7u17-linux-x64.rpm
以上安装如发生小错误可以百度一下,跟据自身情况作小调整,本教程主要是针对后期出错部分的处理,目前未见网络上有出错的处理办法资料,并且相关资料并不全面。
-
JDK环境变量的配置:
方法一:$vi /etc/profile
输入o,在最后加入以下内容:
#set java environment
export JAVA_HOME=/usr/java/jdk1.8.0_05
export JRE_HOME=/usr/java/jdk1.8.0_05/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$JAVA_HOME/lib
export JACA_HOME
export PATH
export CLASSPATH
然后使环境变量立即生效
$source /etc/profile
测试是否成功
输 入#java -versionjava version "1.8.0_05"Java(TM) SE Runtime Environment (build 1.8.0_05-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
方法二:
[root@cc]# sudo nautilus
跳出来的窗口上选择文件=》打开父文件=》找到etc=》找到profile(可以在位置处搜profile)打开profile,在最下面加入
#set java environment
export JAVA_HOME=/usr/java/jdk1.8.0_05
export JRE_HOME=/usr/java/jdk1.8.0_05/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$JAVA_HOME/lib
export JACA_HOME
export PATH
export CLASSPATH
测试是否成功
输 入#java -versionjava version "1.8.0_05"Java(TM) SE Runtime Environment (build 1.8.0_05-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
-
安装android sdk
1.下载android sdk
此处本人在/home/cc/自己的用户下创建了文件夹kaifa
2.我把刚下的adt-bundle-linux-x86_64-20140321(我的是64位的,这在之后可能会出现adb错误的问题,之后会解决)提取到了/home/cc/kaifa里面
3打开/home/cc/kaifa/adt-bundle-linux-x86_64-20140321/eclipse/eclipse
4.运行eclipse后点Source下方的安卓下载图标(鼠标在那停留会提示android SDK Manager)点开后点右下方lnstall 86 packages...把你需要的包下载下来,这可能需要一些时间,有的包没下好,就重点在接着下。
5.配置变量环境
方法一:
命 令:vi ~/.bashrc ,在末尾加入以下内容: export PATH=$PATH{}:/home/cc/kaifa/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/home/cc/kaifa/adt-bundle-linux-x86_64-20140321/sdk/tools
然后按Esc,在按“:”,输入wq
重启电脑
方法二:
[root@cc]# sudo nautilus
在打开的root文件夹内找到.bashrc文件,在最后加上
export PATH=$PATH{}:/home/cc/kaifa/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/home/cc/kaifa/adt-bundle-linux-x86_64-20140321/sdk/tools
然后保存,重启电脑
-
安装ADT
1.打开eclipse
2.点击hlep
3.点lnstall New Software...
4.在Work wifh:里输入https://dl-ssl.google.com/android/eclipse/
然后回车。注意,没错是https
5.等一会后,在Name下面会有两个文件,都勾起来点Cancel
然后点下一步,点OK
提示按装ADT时候有可能出现错误。原因是adb的问题
在命令中打入adb会出现提示错误或没有,解决办法如下
-
如果出现错误那就是因为adb是32位的,要装ia32-libs。ubuntu下面是sudo apt-get install ia32-libs
可是centos不行,centos是不能安装deb的,不过你可以解压deb后使用。
在命令中打入
#yum install glibc.i686
什么?你的不行吗? 对,可能有的在打入这个命令时候没有glibc.i686。那怎么办呢,接下来复制下面这个长命令,然后输入执行:
#yum install alsa-lib-devel.i686 alsa-lib-devel audiofile-devel.i686 audiofile-devel cups-devel.i686 cups-devel dbus-devel.i686 dbus-devel fontconfig-devel.i686 fontconfig-devel freetype.i686 freetype-devel.i686 freetype-devel giflib-devel.i686 giflib-devel lcms-devel.i686 lcms-devel libICE-devel.i686 libICE-devel libjpeg-turbo-devel.i686 libjpeg-turbo-devel libpng-devel.i686 libpng-devel libSM-devel.i686 libSM-devel libusb-devel.i686 libusb-devel libX11-devel.i686 libX11-devel libXau-devel.i686 libXau-devel libXcomposite-devel.i686 libXcomposite-devel libXcursor-devel.i686 libXcursor-devel libXext-devel.i686 libXext-devel libXi-devel.i686 libXi-devel libXinerama-devel.i686 libXinerama-devel libxml2-devel.i686 libxml2-devel libXrandr-devel.i686 libXrandr-devel libXrender-devel.i686 libXrender-devel libxslt-devel.i686 libxslt-devel libXt-devel.i686 libXt-devel libXv-devel.i686 libXv-devel libXxf86vm-devel.i686 libXxf86vm-devel mesa-libGL-devel.i686 mesa-libGL-devel mesa-libGLU-devel.i686 mesa-libGLU-devel ncurses-devel.i686 ncurses-devel openldap-devel.i686 openldap-devel openssl-devel.i686 openssl-devel zlib-devel.i686 pkgconfig sane-backends-devel.i686 sane-backends-devel xorg-x11-proto-devel glibc-devel.i686 prelink fontforge flex bison libstdc++-devel.i686 pulseaudio-libs-devel.i686 gnutls-devel.i686 libgphoto2-devel.i686 openal-soft-devel openal-soft-devel.i686 isdn4k-utils-devel.i686 gsm-devel.i686 samba-winbind libv4l-devel.i686 cups-devel.i686 libtiff-devel.i686 gstreamer-devel.i686 gstreamer-plugins-base-devel.i686 gettext-devel.i686 libmpg123-devel.i686
安装过后,重新安装ADT,方法回到第四条安装ADT,安装完成后就可以了
祝你成功