ubuntu 上android 源码编译 全过程(一)

1.安装ubuntu系统


2.安装jdk环境


3.配置编译环境


4.解决编译过程中遇到的问题


5.编译成功


问题解决总结:


资源版本

开始用的ubuntu 14.10 遇到一个大问题搞了两天没弄好,建议不要选择14.10

问题是 build/core/prebuilt.mk:143:*** recipe commences before first target.停止 遇到这个问题的绕道吧(个人建议)


现在的环境情况:


ubuntu12.04 、jdk1.6.33、源码4.0.3


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


安装Ubuntu系统:


要求:


1.最好是64位的操作系统。至于windows支持不支持直接boot设置,重启f1 vm。。。切换enabled 保存,然后新建虚拟机选择ubuntu64位一定要

3.版本最好是12.04 因为12.04 我还可以提供更新源基本可以解决好多问题

1、首先备份Ubuntu12.04源列表

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup (备份下当前的源列表)

 

2、修改更新源

sudo gedit /etc/apt/sources.list (打开Ubuntu 12.04源列表文件)

 

3、把里面的列表替换成下面的列表

163源

技术分享
deb http://mirrors.163.com/ubuntu/ precise main restricted
deb-src http://mirrors.163.com/ubuntu/ precise main restricted
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb http://mirrors.163.com/ubuntu/ precise universe
deb-src http://mirrors.163.com/ubuntu/ precise universe
deb http://mirrors.163.com/ubuntu/ precise-updates universe
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
deb http://mirrors.163.com/ubuntu/ precise multiverse
deb-src http://mirrors.163.com/ubuntu/ precise multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted
deb http://mirrors.163.com/ubuntu/ precise-security universe
deb-src http://mirrors.163.com/ubuntu/ precise-security universe
deb http://mirrors.163.com/ubuntu/ precise-security multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
技术分享

 

sohu源

技术分享
deb http://mirrors.sohu.com/ubuntu/ precise main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb http://mirrors.sohu.com/ubuntu/ precise universe
deb-src http://mirrors.sohu.com/ubuntu/ precise universe
deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb http://mirrors.sohu.com/ubuntu/ precise multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-security universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe
deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
技术分享

 

ubuntu.cn99.com源(推荐):

deb http://ubuntu.cn99.com/ubuntu/ precise main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ precise-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ precise main restricted universe multiverse

 

教育网源
如果你是在校大学生,可以使用校园网/教育网,就是用教育网的资源吧,尤其是支持ipv6的,那更新速度就按兆算了。

#电子科技大学

技术分享
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
技术分享

 

#中国科技大学

技术分享
deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
技术分享

 

#北京理工大学

技术分享
deb http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
技术分享

 

4、更新源

sudo apt-get update

这时候基本ubuntu安装环境搭好了。接下来就是jdk 和源码编译了


我选择的手动下载jdk1.6.0_33,要的到我资源里下载,稍后上传。 

1、为jdk-6u33-linux-i586.bin增加执行权限




    chmod u+x /usr/lib/jvm/java/jdk-6u33-linux-i586.bin


2、执行jdk-6u33-linux-i586.bin,将JDK6的相关文件解包至jdk1.6.0_33目录下


    ./jdk-6u33-linux-i586.bin


3、将jdk1.6.0_33复制到/usr/lib下


    mkdir -p /usr/lib/jvm/


    cp -r jdk1.6.0_33 /usr/lib/jvm/jdk1.6.0_33


4、安装JDK6


    JDK6的bin文件中有许多可执行命令,根据需要,可以选择安装至/usr/bin目录下,比如,我安装了java/javac/javaws/jar四个命令。具体执行如下命令:


    update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1


    update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1


    update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1


    update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_33/bin/jar 1


    update-alternatives --config javac


    update-alternatives --config java


    update-alternatives --config javaws


    update-alternatives --config jar


    注意:如果需要安装其它命令,按照上面的格式,根据需要进行添加即可。


5、测试


    ?执行java -version可以看到当前JDK的版本信息,表示安装成功。显示如下:


    root@ubuntu:~/JDK# java -version


    java version "1.6.0_33"





    Java(TM) SE Runtime Environment (build 1.6.0_33-b04)


    Java HotSpot(TM) Server VM (build 20.8-b03, mixed mode)

其实到这没有结束因为ubuntu自带的openjdk与jdk1.6冲突的,解决下后面会少很多错误的


比如把我到jdk1.6安装到/usr/java下

1.下载jdk 我下载到是jdk-6u23-linux-i586.bin
2.把jdk-6u23-linux-i586.bin拷贝到/usr/java目录下
3.cd /usr/java
4.chmod +x jdk-6u23-linux-i586.bin
5. ./jdk-6u23-linux-i586.bin
6. 配置环境变量
   所有用户:
       gedit /etc/profile
    在末尾处加入:
   export JAVA_HOME=/usr/java/jdk1.6.0_23
   export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
   export PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
7.由于ubuntu中可能会有默认的jdk,如openjdk,所以,为了使默认使用的是我们安装的jdk,还要进行如下工作
   
update-alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_23/bin/java 300

update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_23/bin/javac 300

8. java -version


到这里jdk才算完全安装完毕,有别的问题可以继续道网上搜



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。