原文网址:http://blog.csdn.net/hudan2714/article/details/7926924

一、编译环境:
首先介绍编译中使用的工具:
虚拟机:    vmare 9 下载地址:http://blog.csdn.net/hudan2714/article/details/7902654
linux平台:ubuntu 12.04 64位
jdk:              sun-java6-jdk (64位)
交叉编译工具链:gcc 使用的版本是:4.6.3 
 
想要完成最终的编译,当然首要的就是检查环境:
1、安装的ubuntu设置空间大小:至少需要30G
     目前下载的包就有10G:有图有真相:
       
       包括解压编译后大小有30G了:
     
 
      所以空间一定要够了才行。
 
2、gcc和g++不能使用使用4.4版本了(编译android4.0系统使用的是4.4),
                       现在只要使用系统自带的4.6.3(ubuntu12.04) 就可以了。
      
 
3、jdk版本:sun-java6-jdk
        
 
 
二、编译:
        编译过程不知道,可以查看官方文档了。这里做简单说明:
        1.source build/envsetup.sh   这是向系统导入不同的厂商版本,并添加m命令。
        2.lunch 选择编译厂商版本。
        3.mm    编译版本
 
         还是看图说话吧:
           
 
            当然这里的lunch full-eng是编译所有,如果嫌慢,就单独编译某一个也可。
             
 
              再mm就可以编译了(必须要source了,才有mm命令,而且只在此terminal有效)
               
 
 
三、编译中遇到的错误:
       错误太多,做了一些总结,有点乱,如果编译过程中遇到错误,可以来查看:
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解决方法:sudo apt-get install bison
 
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解决方法: sudo apt-get install flex
 
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
解决方法:sudo apt-get install gperf
 
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directoryIn file included from /home/hudan/android/source/android4.1.1/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../sysroot/usr/include/sys/types.h:27:0,
                 from frameworks/native/include/utils/Errors.h:20,
                 from frameworks/native/include/utils/String8.h:20,
                 from cts/suite/audio_quality/lib/include/Settings.h:21,
                 from cts/suite/audio_quality/lib/src/Settings.cpp:17:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directoryIn file included from /usr/include/stdlib.h:25:0,
                 from cts/suite/audio_quality/lib/src/Adb.cpp:16:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
 
compilation terminated.
compilation terminated.
 
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libcts_audio_quality_intermediates/src/SimpleScriptExec.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libcts_audio_quality_intermediates/src/Adb.o] Error 1
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libcts_audio_quality_intermediates/src/Settings.o] Error 1
In file included from /usr/include/semaphore.h:22:0,
                 from cts/suite/audio_quality/lib/include/Semaphore.h:21,
                 from cts/suite/audio_quality/lib/src/Semaphore.cpp:17:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libcts_audio_quality_intermediates/src/Semaphore.o] Error 
解决方法:sudo apt-get install gcc-multilib 
 
 

error libGL.so: cannot open shared object file: No such file or directory

OSError: libGL.so: cannot open shared object file: No such file or directory

may appear on Linux systems when you try to launch VNL for the first time. To solve it, create (as administrator) a new link in /usr/lib:

sudo ln -s /usr/lib/libGL.so.1.2 /usr/lib/libGL.so

If you have a 64-bit Linux, use /usr/lib64 instead.

First check that you actually have "libGL.so.1.2" in /usr/lib or /usr/lib64; it might be called "libGL.so.1" or something else instead, or located in another directory, depending on the video drivers. You can use

locate libGL

to find the correct file to link to.

而我使用的是ubuntu 12.04 bit-64位,在/usr/lib/并没有libGL.so文件。

可以使用locate libGL查找此文件。结果:

找出了这么多,当然是选择64位平台下的libGL了。

但是针对这几个,不知道要选择哪一个好,还请高手指点。

Failed to load libGL.so

error libGL.so: wrong ELF class: ELFCLASS64

linux系统是64位的,这个命令不支持64位

最佳解决方案,把oralce-lib环境变量设置为lib32即可

最后选择ln还36位

代码:hudan@ubuntu:~/android/source/android4.1.1/out$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so

 
再运行编译好的system.img,出现如下的错误:

直接参数-ramdisk ramdisk.img去掉,结果模拟器跑起来了,但不能把内核启动起来。

no ABI error , when creating an Android virtual device

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

解决:sudo rm /var/lib/apt/lists/lock
 
 

sh: gperf: not found

target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h'

解决方法:sudo apt-get install gperf

n file included from /usr/include/stdlib.h:25,
                 from build/tools/acp/acp.c:11:
/usr/include/features.h:323: 致命错误: bits/predefs.h:没有那个文件或目录编译中断。
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] 错误 1

make: *** [out/host/linux-86/obj/STATIC_LIBRARIES/libcts_audio_quality_intermediates/src/Adb.o] Error 1

安装:libc6-dev-i386
     sudo apt-get install libc6-dev-i386

make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so] Error 1

make: *** Waiting for unfinished jobs....

make: *** [out/target/common/obj/APPS/android.core.tests.libcore.package.dalvik.no-core-tests-res_intermediates/noproguard.classes-with-local.dex] Error 130

上次make或或者mmm的时候生成一些错误的东西

可以使用:make clean 再重新make

解决:rm out/target/common/obj/APPS/ -r (如果还是有这样的错误,就只能clean了)

 
四、运行编译好的系统
vi /etc/profile
增加以下三句
最终运行配置,给大家截个图:
只需要这三句就OK
 
配置完,source /etc/profile 要是出现黑屏,建议重启一下。接下:
 
运行时只要:emulator
 
完美运行:
 
下面是遇到的问题,可以看看:
 
编译完系统后,用模拟器运行系统,在2.3之前只需要配置:
export ANDROID_PRODUCT_OUT=/home/hudan/android/source/android4.1.1/out/target/product/generic_x86
export PATH=$PATH:/home/hudan/android/source/android4.1.1/out/host/linux-x86/bin
但这样配置就一直出现如下的错误:
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.
 
If you are an Android SDK user, please use '@<name>' or '-avd <name>'
to start a given virtual device (see -help-avd for details).
 
Otherwise, follow the instructions in -help-disk-images to start the emulator
最后配置export ANDROID_BUILD_TOP=/home/hudan/android/source/android4.1.1
一切就都OK了。
 
 
如果是研究android源码的欢迎加群交流:android系统高级交流群:247039470
 

【转】android4.1.1系统编译全过程的更多相关文章

  1. 在ubuntu14.04上编译android4.2.2系统

    原创作品,转载请注明出处,严禁非法转载             copyright:weishusheng   2015.8.1 时下android系统非常流行,下面就来说一下,下载编译一个andro ...

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

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

  3. 【转】Linux(ubuntu14.04)上编译Android4.4源码的环境搭建及编译全过程

    原文网址:http://jileniao.net/linux-android-building.html sublime text让我伤心.本来很信任sublime text的自动保存功能,之前使用一 ...

  4. 利用qemu模拟嵌入式系统制作全过程

    http://www.tinylab.org/using-qemu-simulation-inserts-the-type-system-to-produce-the-whole-process/ 利 ...

  5. Android系统编译时遇到的几个.mk的疑惑。

    在Android4.2的源代码Build/prduct_config.mk里面遇到几个疑惑: # Convert a short name like "sooner" into t ...

  6. Mac系统编译FFmpeg

    转载请标明来源:我不是掌柜的博客 前言 维基百科解释:FFmpeg是一个开源软件,可以运行音频和视频多种格式的录影.转换.流功能,包含了libavcodec – 这是一个用于多个项目中音频和视频的解码 ...

  7. 迅为iTOP-4418开发板-Android5.1系统编译补充

    基于iTOP-4418开发板-Android5.1系统编译补充 5.6 编译-20181225 日期之后的源码 本文档补充介绍 4418 编译网盘目录 “J:\局域网共享_阮\iTOP4418 开发板 ...

  8. RockChip RK3326 系统编译问题总结

    1. 序言 本文主要记录了RK3326平台系统编译过程中遇到的各种问题,并加以解决! 环境: 宿主Linux:Ubuntu 16.04 目标机:RK3326 (64bit) Toolchain:gcc ...

  9. chromium os系统编译与环境搭建

    官方网址:http://www.chromium.org/chromium-os chromium os是google自2009年开启的项目,是一款开源的电脑操作系统,用于开发chromium/chr ...

随机推荐

  1. gitcafe 使用hexo搭建博客

    --缘由:因为看大家都用github等搭建博客,作为半个程序员的自己,也按捺不住了,终于有空来尝试一把了,选择了和github 相同功能的gitcafe网站,因为在国内比较快,这是大家的看法,下面写一 ...

  2. portal开发"下拉框"“日期框”查询要怎么配置

    下面的这些是我今天的成果! 总的来说是一步一步摸索出来的!还是等感谢超哥的耐心指导,犯了一些错误! 1.比如在wd配置文件中中写id=“check_it_two”,在java中写成 checki_it ...

  3. C# 反射之属性操作

    一.反射-类操作 //1.获取对象所有的属性名 Student stu = new Student(); //获取当前类名称 Console.WriteLine(stu.GetType().Name) ...

  4. 在jsp中用EL 表达来获取表单中的参数

     在一个JSP页面转到另一个JSP页面时,对表单中的参数用EL表达式提取为:     <form action="sampleJsp.jsp" method="po ...

  5. Gulp(一)

    一.简介 gulp 是基于 Nodejs 的自动任务运行器,能自动化地完成javascript/coffee/sass/less/html/image/css等文件的的测试.检查.合并.压缩.格式化. ...

  6. java_泛型(2016-11-17)

    没有自己敲,这篇博客讲的不错,直接记录. 犯懒啊 重点关注 T,?以及擦除 Java总结篇系列:Java泛型:http://www.cnblogs.com/lwbqqyumidi/p/3837629. ...

  7. gpfdist工具的初级使用

    gpfdist工具的使用主要两步: 第一步:打开gpfdist服务: gpfdist -d /home/admin -p -l /tmp/gpfdist.log & 参数解释: -d 数据文件 ...

  8. jquery中mouseout和mouseleave 事件的区别

    今天用jQuery写了一个选项卡的效果,用mouseout事件控制了鼠标的移出,结果发现在移出时div会发生闪动,于是网上各种查资料觉得用mouseleave更合适一些,

  9. 使用Node.js作为后台进行爬虫

    看了一遍又一遍Node.js但是没过多久就又忘了,总想找点东西来练练手,就发现B站首页搜索框旁边的GIF图特别有意思,想着是不是可以写一个小Node.js项目把这些图全部扒下来,于是带着复习.预习与探 ...

  10. 帝国cms 灵动标签【列表页】调用当前父栏目下的所有子栏目

    <? $bclassid = $class_r[$GLOBALS[navclassid]][bclassid]; //获取当前父栏目ID ?> [e:loop={"select ...