Ubuntu12.04编译Android2.3.4

1.下载Ubuntu
ubuntu-12.04-dvd-i386.iso
2.使用U盘安装,启动盘制作用unetbootin-windows-568工具即可
3.虚拟机用的是VMware-workstation-full-8.0.2-591240.exe破解版本,或者直接安装在机器上
4.虚拟机安装vmware tools  
打开虚拟机,点击install vmware tools
把 vmware tools拖到桌面上(命令复制时由于有空格 需要添加双引号“”),ctrl+alt+t进入终端,输入sudo su 输入密码获取root权限,然后把vmware tools CP到/tmp中tar vzxf vmwaretools解压后到 vmware-tools-distrib里面输入./vmware-install.pl安装,根据提示到出现enjoy,--the vmware team就成功安装了。
可以通过在终端中输入如下命令来运行它: 
$ /usr/bin/vmware-toolbox 
或者让vmware-toolbox实现开机自动运行。
点击Ubuntu菜单:System——首选项——会话—— Startup Programs,Add一个Name叫“vmware-toolbox”,Command是“/usr/bin/vmware-toolbox”的启动程序。这样每次开机后就能自动运行VMware Tools了
5.更新源
sudo cp /etc/apt/sources.list /etc/apt/sources.list_back (这是备份源列表) 
sudo gedit /etc/apt/sources.list   (这是编辑源列表)
sudo cp /etc/apt/sources.list_backup /etc/apt/sources_list(恢复源列表)
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install ubuntu-restricted-extras
一些常用的源列表:
deb http://cn.archive.Ubuntu.com/ubuntu/ natty multiverse
deb-src http://cn.archive.Ubuntu.com/ubuntu/ natty multiverse
deb http://cn.archive.Ubuntu.com/ubuntu/ natty-updates multiverse
deb-src http://cn.archive.Ubuntu.com/ubuntu/ natty-updates multiverse
deb http://security.Ubuntu.com/ubuntu natty-security main restricted
deb-src http://security.Ubuntu.com/ubuntu natty-security main restricted
deb http://security.Ubuntu.com/ubuntu natty-security universe
deb-src http://security.Ubuntu.com/ubuntu natty-security universe
deb http://security.Ubuntu.com/ubuntu natty-security multiverse
deb-src http://security.Ubuntu.com/ubuntu natty-security multiverse
deb http://archive.canonical.com/Ubuntu natty partner
deb-src http://archive.canonical.com/Ubuntu natty partner
台湾源
deb http://tw.archive.Ubuntu.com/ubuntu/ natty main universe restricted multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu/ natty main universe restricted multiverse
deb http://tw.archive.Ubuntu.com/ubuntu/ natty-security universe main multiverse restricted
deb-src http://tw.archive.Ubuntu.com/ubuntu/ natty-security universe main multiverse restricted
deb http://tw.archive.Ubuntu.com/ubuntu/ natty-updates universe main multiverse restricted
deb-src http://tw.archive.Ubuntu.com/ubuntu/ natty-updates universe main multiverse restricted
网易源(速度很快)
deb http://mirrors.163.com/Ubuntu/ natty main universe restricted multiverse
deb-src http://mirrors.163.com/Ubuntu/ natty main universe restricted multiverse
deb http://mirrors.163.com/Ubuntu/ natty-security universe main multiverse restricted
deb-src http://mirrors.163.com/Ubuntu/ natty-security universe main multiverse restricted
deb http://mirrors.163.com/Ubuntu/ natty-updates universe main multiverse restricted
deb http://mirrors.163.com/Ubuntu/ natty-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/Ubuntu/ natty-proposed universe main multiverse restricted
deb http://mirrors.163.com/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/Ubuntu/ natty-updates universe main multiverse restricted
上海源
deb http://mirror.rootguide.org/Ubuntu/ natty main universe restricted multiverse
deb-src http://mirror.rootguide.org/Ubuntu/ natty main universe restricted multiverse
deb http://mirror.rootguide.org/Ubuntu/ natty-security universe main multiverse restricted
deb-src http://mirror.rootguide.org/Ubuntu/ natty-security universe main multiverse restricted
deb http://mirror.rootguide.org/Ubuntu/ natty-updates universe main multiverse restricted
deb http://mirror.rootguide.org/Ubuntu/ natty-proposed universe main multiverse restricted
deb-src http://mirror.rootguide.org/Ubuntu/ natty-proposed universe main multiverse restricted
deb http://mirror.rootguide.org/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirror.rootguide.org/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirror.rootguide.org/Ubuntu/ natty-updates universe main multiverse restricted
搜狐源
deb http://mirrors.shlug.org/Ubuntu/ natty main universe restricted multiverse
deb-src http://mirrors.shlug.org/Ubuntu/ natty main universe restricted multiverse
deb http://mirrors.shlug.org/Ubuntu/ natty-security universe main multiverse restricted
deb-src http://mirrors.shlug.org/Ubuntu/ natty-security universe main multiverse restricted
deb http://mirrors.shlug.org/Ubuntu/ natty-updates universe main multiverse restricted
deb http://mirrors.shlug.org/Ubuntu/ natty-proposed universe main multiverse restricted
deb-src http://mirrors.shlug.org/Ubuntu/ natty-proposed universe main multiverse restricted
deb http://mirrors.shlug.org/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.shlug.org/Ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.shlug.org/Ubuntu/ natty-updates universe main multiverse restricted
6.Android版本代号
Code name  Version    API level 
(no code name)   1.0    API level 1 
(no code name)   1.1    API level 2 
Cupcake   1.5    API level 3, NDK 1 
Donut    1.6    API level 4, NDK 2 
Eclair    2.0          API level 5 
Eclair                  2.0.1    API level 6 
Eclair    2.1                     API level 7, NDK 3 
Froyo    2.2.x    API level 8, NDK 4 
Gingerbread   2.3 - 2.3.2   API level 9, NDK 5 
Gingerbread   2.3.3 - 2.3.7   API level 10 
Honeycomb   3.0    API level 11 
Honeycomb   3.1    API level 12, NDK 6 
Honeycomb   3.2.x    API level 13 
IceCreamSandwich  4.0.1 - 4.0.2   API level 14, NDK 7 
IceCreamSandwich  4.0.3 - 4.0.4   API level 15

7.Android编译环境配置
vim ~/.bashrc添加:
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_32 
export JRE_HOME=${JAVA_HOME}/jre
export HOME_BIN=~/bin/
export CLASSPATH=.:${JAVA_HOME}/lib:$JRE_HOME/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export ANDROID_SDK_HOME=/home/xch/bin/out/host/linux-x86/sdk/android-sdk_eng.xch_linux-x86
export ANDROID_PRODUCT_OUT=/home/xch/bin/out/target/product/generic
export PATH=${PATH}:${JAVA_PATH}:${HOME_BIN}:${ANDROID_SDK_HOME}/tools

默认的PATH,防止修改PATH后出错,可以用来修正
export   PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
修改完后source ~/.bashrc一下就可以了

8.Android源码下载
可参考官方文档:http://source.android.com/source/downloading.html
可能需要预先安装一些软件:
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
sudo apt-get install make
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install libc6-dev
sudo apt-get install patch
sudo apt-get install texinfo
sudo apt-get install zlib1g-dev
sudo apt-get install valgrind
sudo apt-get install python2.5(或者更高版本)
sudo apt-get install curl
sudo apt-get install sun-java5-jdk或者1.6

$ mkdir ~/bin
$ PATH=~/bin:$PATH(这一步在前面环境变量那里设置了)
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
repo init -u https://android.googlesource.com/platform/manifest  -b android-2.3.4_r1
repo sync

如果下载源码出现被拒绝的错误,可以google一下解决方法,下面是其中一个解决方法:
curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo  
chmod a+x ~/bin/repo  
PATH=~/bin:$PATH  
mkdir WORKING_DIRECTORY  
cd WORKING_DIRECTORY  
//repo init -u git://codeaurora.org/platform/manifest.git -b gingerbread  
repo init -u git://codeaurora.org/platform/manifest.git -b android-2.3.4_r1
repo sync
然后漫长的等待......
9.编译源码
32位机要修改下面的文件:
build/core/main.mk
        ifeq ($(BUILD_OS),linux)
build_arch := $(shell uname -m) 
---ifneq (64,$(findstring 64,$(build_arch))) 
+++ifneq (i686,$(findstring i686,$(build_arch)))
$(warning
************************************************************)
$(warning You are attempting to build on a 32-bit system.)
 $(warning Only 64-bit build environments are supported beyond
froyo/2.2.)
(--- means delete that line, +++ means add that line)
and change the code in four mk files below from “+=-m64” to “+=-m32”
external/clearsilver/cgi/Android.mk
external/clearsilver/java-jni/Android.mk
external/clearsilver/util/Android.mk
external/clearsilver/cs/Android.mk        
LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32

编译过程中出现下面2个问题及解决方法:
1.[out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] error  1
$ gedit frameworks/base/libs/utils/Android.mk
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)改为:LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
2.make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]   error 1
/build/core/combo/HOST_linux-x86.mk
HOST_GLOBAL_CFLAGS
+= -D_FORTIFY_SOURCE=0
修改为:
HOST_GLOBAL_CFLAGS
+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
然后就可以编译了:
$make -j2(使用2个线程编译)漫长的等待....
编译SDK
$make PRODUCT-sdk-sdk(又是漫长的等待....)
成功后可用模拟器测试:
$emulator

Ubuntu12.04编译Android2.3.4的更多相关文章

  1. Android编译环境——ubuntu12.04上android2.3.4编译错误以及解决

    Android编译环境——ubuntu12.04上android2.3.4编译错误以及解决 分类: android应用开发2013-08-21 09:20 4222人阅读 评论(3) 收藏 举报 li ...

  2. 转:Ubuntu12.04编译VLC,在linux上运行

    Ubuntu12.04编译vlc2.1.0 1.编译环境 VM8.0.1 # gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAP ...

  3. Ubuntu12.04编译Android4.0.1源码全过程-----附wubi安装ubuntu编译android源码硬盘空间不够的问题解决

    昨晚在编译源码,make一段时间之后报错如下: # A fatal error has been detected by the Java Runtime Environment: # # SIGSE ...

  4. Ubuntu12.04编译vlc-android详细流程

    作者:wainiwann 出处:http://www.cnblogs.com/wainiwann/ 本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则 ...

  5. ubuntu12.04编译rtems doc目录

    我的rtem的版本是rtems-4.10.2:首先安装textinfo:sudo apt-get install texinfo 然后: cd rtems-4.10.2/doc../bootstrap ...

  6. Ubuntu12.04安装64位系统出现编译错误error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or dir

    问题: Ubuntu12.04安装64位系统出现编译错误error while loading shared libraries: libz.so.1: cannot open shared obje ...

  7. ubuntu12.04下安卓编译环境搭建总结

    前言:      因为工作需要,经常要编译安卓下的动态库,公司有已经搭建好环境的服务器,但是第一自己想自己搭建一下了解一个整个过程,另外,公司的服务器也经常出现问 题,导致编译不了,所以就想自己搭建环 ...

  8. 在ubuntu12.04下编译android4.1.2添加JNI层出现问题

    tiny4412学习者,在ubuntu12.04下编译android4.1.2添加JNI层出现问题: (虚心请教解决方法) trouble writing output: Too many metho ...

  9. [置顶] ubuntu12.04下编译opencv程序

    ubuntu12.04下编译opencv程序 1.在ubuntu下安装好 opencv后(建议使用apt-get install 来安装) 2.使用程序FaceExaple.c来进行测试程序 #inc ...

随机推荐

  1. Recommended Practices for WPF Custom Control Developers

    I have always found that there isn’t enough documentation about Custom Control development in WPF. M ...

  2. 10、QT分析之WebKit

    该文章整理自 网易博客 http://blog.163.com/net_worm/blog/static/12770241920101831312381/ 转载请注明出处 WebKit是QT4新整合的 ...

  3. 【转】【Android】Android Studio打包全攻略

    项目写完了,现在需要把应用上传到市场,问题出现—怎么把代码变成.apk(Android的可安装文件).1. 创建签名文件2. 填写好签名参数3. 生成APK注意:签名的密码和密匙的密码注意保管,不要忘 ...

  4. 关于使用mybatis的一个惨痛教训

    事情大概是这样的: 某个时刻之后所有的交易都崩溃了,查看数据库得知所有的数据都变成一样的了!!! 再查看log,发现执行了这样的语句:UPDATE XXX SET c1=v1,c2=v2 ...,没有 ...

  5. (转)编译android5.1,添加swap分区的方法

    clang++: error: unable to execute command: Killedclang++: error: assembler command failed due to sig ...

  6. MQ遇到的错误(2035 或 2013认证错误)

    java 连接 IBM MQ时出现 2035 或 2013认证错误的解决 com.ibm.msg.client.jms.DetailedJMSSecurityException: JMSWMQ2013 ...

  7. SSH命令详解2

    ssh命令详解     目录         前言     一.ssh命令         1.Ssh参数解释         2.如何连接远程主机         3.利用Xstart 在windo ...

  8. discuz密码找回:[1]忘记UCENTER创始人密码

    人们都是健忘的,何况每天的事情很多,有些站长更是兼职做,赚点外快而已,而ucenter更是不常用,所以忘记密码是在正常不过的事情,如果密码忘记怎么找回呢?方法有很多种,例如用comsenz tools ...

  9. css 阻止元素中的文本。双击选中

    //firefox -moz-user-select: none; //chrome.safari -webkit-user-select: none; //ie -ms-user-select: n ...

  10. 【转】在64位windows下使用instsrv.exe和srvany.exe创建windows服务

    本文转自:https://www.iflym.com/index.php/computer-use/201205020001.html 在32位的windows下,包括windows7,windows ...