Configure the android development environment on centos7

1. System configuration

        The company's computer has been used for a period of time and then replaced with other systems, and the configuration process is recorded here.

        

        Log in with ROOT privileges

 

2. Preliminary configuration

    HOST configuration           

    add in hosts file

         203.208.46.146 dl.google.com

         203.208.46.146 dl-ssl.google.com

 

          #vim /etc/hosts

          为了之后下载SDK。

         PS:进入vim,默认是命令模式,按下“i”键进入插入模式进行编辑,编辑完按ESC进入命令模式,输入“:wq”保存退出。

    Download 32-bit lib library            

    因为Android SDK需要32bitlib才可以运行,而当前环境是64bit的,所以需要下载安装32bitlib

            yum install glibc.i686

            yum install zlib.i686

 

三、下载Eclipse

                这里有两个选择:

                1.在Eclipse官网下载最新版本:        http://www.eclipse.org/downloads/        

                2. Download ADT on the official Android developer website, which includes the IDE. The advantage is that it eliminates a lot of subsequent configuration.

                    http://developer.android.com/sdk/index.html

            But I still prefer to do each step by myself, so I made the first choice.

 

Fourth, configure the JAVA environment

                CentOS 6.5 has installed the OpenJDK environment for you, which can be checked with the following command. But I still want to use Oracle JDK, so I disassemble OpenJDK first.                

        java -version

        java version "1.6.0"
        OpenJDK Runtime Environment (build 1.6.0-b09)
        OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

                1. Disassemble OpenJDK

                           Query installed java packages

                rpm -qa | grep java

                java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

                java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

                拆卸

                rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

                rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

                如果出现找不到openjdk source的话,那么还可以这样卸载

                yum -y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

                yum -y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

          2、安装JDK

            从Oracle官网上下载JDK,我这里下载的版本jdk-6u45-linux-x64-rpm.bin

                修改可执行权限

                chmod +x jdk-6u21-linux-i586-rpm.bin

              执行

                    ./ jdk-6u21-linux-i586-rpm.bin

              执行成功后,可以看到jdk1.6.0_45这个文件夹

            3.配置JAVA环境变量

                环境变量配置在/etc/profile文件中

                # vim /etc/profile

                在profile文件末尾添加配置信息,我的java jdk存放达路径在/usr/java目录下

                    export JAVA_HOME=/usr/java/jdk1.6.0_45

                    export JAVA_BIN=/usr/java/jdk1.6.0_45/bin

                    export PATH=$PATH:$JAVA_HOME/bin

                    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

                    export JAVA_HOME JAVA_BIN PATH CLASSPATH

                查询java版本

                    #java -version

                    java version "1.6.0_45"

                    Java(TM) SE Runtime Environment (build 1.6.0_45-b06)

                    Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

 

五、下载ADT             

         1) 通过Ecplise中安装ADT

            Ecplise->Help->Install New Software->Add

             Location输入:http://dl-ssl.google.com/android/eclipse/

            一路下一步,需要同意的勾选下。安装完毕重启Ecplise后,ADT就安装好了。

        2) 手动安装ADT

            Android官网上下载ADT

            下载地址:http://developer.android.com/sdk/index.html

            我下载的是:adt-bundle-linux-x86_64-20131030.zip

            解压后,里面已经包含了EclipseSDK

             Eclipse已安装了ADT

 

六、更新Android SDK

                Android SDK Manager界面->Tools->Options->Others

        勾选Force https://...sources to be fetched using http://...

        同时配置Host

 

七、错误处理

        新建一个Android项目,运行项目时报错:

            Unable to execute dex: java.nio.BufferOverflowException.

       移除项目中Android Dependencies即可

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326665820&siteId=291194637