通过参考网上的相关资料,我编译Android源码的步骤如下:

  • 1 我的系统是Ubuntu 8.04
  • 2 系统上必须安装以下工具(摘自网上的资料):
     
     sudo apt-get install build-essential
     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 flex
     sudo apt-get install bison
     sudo apt-get install patch
     sudo apt-get install texinfo
     sudo apt-get install libncurses-dev
     
     sudo apt-get install git-core gnupg  //(gnupg系统可能已自带)
     sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
     sudo apt-get install ncurses-dev 
     sudo apt-get install zlib1g-dev
     sudo apt-get install valgrind(可选,有21M大,我觉得一般人是用不到的)
     sudo apt-get install python2.5 (实际上不用装,Ubuntu 8.04 已经自带)
     sudo apt-get install sun-java5-jdk
     
     注意:
     a. 不要用 sun-java6-jdk, 不然在make sdk, 具体来说是make doc这一步中, 遇到这个错误:
       Docs droiddoc: out/target/common/docs/dx
       javadoc: error - In doclet class DroidDoc, method start has thrown an
       exception java.lang.reflect.InvocationTargetException
       com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
       sun.util.resources.OpenListResourceBundle not found
     b. 网上资料说需要设置环境变量, 但我并没有设置:
      export ANDROID_JAVA_HOME=$JAVA_HOME
      
     c. 网上并没有提及要安装ncurses-dev, 但安装之前我编译过程中会出现编译错误.
  • 3 建立android源码的存放目录
     $ mkdir ~/open_src
     $ mkdir ~/open_src/android
     $ cd ~/open_src/android
     $ mkdir bi
  • 4 下载repo脚本,放到~/open_src/android/bin目录下,加上可执行权

$ curl http://android.git.kernel.org/repo > repo
          $ sudo mv repo ~/open_src/android/bin
          $ sudo chmod a+x ~/open_src/android/bin/repo

  • 5 在源码存放目录android中执行
     $ ~/open_src/android/bin/repo init -u git://android.git.kernel.org/platform/manifest.git
     //中间会提示输入电子邮件什么的,如果你打算要提交patch的话,用google accounts注册过的邮箱
  • 6 在android目录中执行repo sync就可以开始下载源码了.
     我们也可以从其他地方把源码复制到android目录, 而我正是这么做的.
  • 7 编译源码, 并得到~/open_src/android/out 目录
     在命令行执行make命令:
     $make
     这是一个很漫长的过程, 等吧......
  • 8 测试运行
     8.1 先设置环境变量:
      打开~/.bashrc文件, 并在最后添加下面两行:
      export PATH=$PATH:~/open_src/android/out/host/linux-x86/bin
      export ANDROID_PRODUCT_OUT=~/open_src/android/out/target/product/generic
     
     8.2 运行模拟器:
      emulator --debug-init -skin QVGA-L  //可能会提示unknown option: --debug-init, 去掉--debug-init即可
      或者直接执行emulator, 这样使用的是默认的皮肤
     
     如果最后能进入到系统并看到一个大时钟, 说明就大功告成了.
  • 9 后续编译:

先在android目录下执行
           $ . build/envsetup.sh
           然后你就会多出几个可用的命令。在改了Contacts联系人项目后,可以简单的执行一下命令来单独编译这个部分:
           $mmm packages/apps/Contacts/
          为了可以直接测试改动,需要生成新的system.img,在android目录下执行:
           $ make snod
          当然,如果你改动的是emulator或者其它外围相关的,而非系统内部的东西,就不只是要重新生成system.img了

  • 以下是编译成功后的最后一些输出:
    Install: out/target/product/generic/system/xbin/scp
    Notice file: system/extras/showmap/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/xbin/showmap.txt
    Install: out/target/product/generic/system/xbin/showmap
    Notice file: system/extras/showslab/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/xbin/showslab.txt
    Install: out/target/product/generic/system/xbin/showslab
    Notice file: external/sqlite/dist/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/xbin/sqlite3.txt
    Install: out/target/product/generic/system/xbin/sqlite3
    Notice file: external/dropbear/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/xbin/ssh.txt
    Install: out/target/product/generic/system/xbin/ssh
    Install: out/target/product/generic/system/xbin/strace
    Notice file: system/extras/su/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/xbin/su.txt
    Install: out/target/product/generic/system/xbin/su
    Install: out/target/product/generic/system/xbin/timeinfo
    Copy: out/target/product/generic/system/etc/apns-conf.xml
    Copying: out/target/product/generic/obj/NOTICE_FILES/src/kernel.txt
    Finding NOTICE files: out/target/product/generic/obj/NOTICE_FILES/hash-timestamp
    Combining NOTICE files: out/target/product/generic/obj/NOTICE.html
    gzip -c out/target/product/generic/obj/NOTICE.html > out/target/product/generic/obj/NOTICE.html.gz
    zip -qj out/target/product/generic/system/etc/security/otacerts.zip build/target/product/security/testkey.x509.pem
    Generated: (out/target/product/generic/android-info.txt)
    Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
    Install system fs image: out/target/product/generic/system.img
    Target ram disk: out/target/product/generic/ramdisk.img
    Target userdata fs image: out/target/product/generic/userdata.img

compile android soure code相关推荐

  1. AS插件-Android Parcelable code generator.

    概述 生成实现了Parcelable接口的代码的插件 下载安装 1.在线安装 输入 Android Parcelable code generator ,点击安装即可,安装之后 重启,会看到上图选中部 ...

  2. 【工程项目经验】Compile Android Error fatal error opening dependency file No such file or directory

    Compile Android Error fatal error opening dependency file No such file or directory 参考网址:https://for ...

  3. Android source code gerrit

    Android source code gerrit 找branch 先在 https://android.googlesource.com/ 找到相关project,如·"platform ...

  4. Creating a Java VM from Android Native Code

    If you're writing native / JNI code for Android, it's probably as native method of an Android app. T ...

  5. 【Win7下Android native code的编译和调试】

    光为这编译及调试环境就前后折腾了两三天,墙外找了很多教程,bill以为以下教程最为贴切 Using eclipse for android - cc Development Using eclipse ...

  6. 【Android QR Code】开源项目:ZXing(一)导入项目

    维基百科:QR Code http://en.wikipedia.org/wiki/QR_code 开源项目:ZXing http://code.google.com/p/zxing/ 1.下载源代码 ...

  7. Downloading Android Source Code

    Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的分布式版本控制软件,它不同于Subversion.CVS这样的集中式版本控制系统.在集中式版本控制系统 ...

  8. Learning English From Android Source Code:1

    英语在软件行业的重要作用不言自明,尤其是做国际项目和写国际软件,好的英语表达是项目顺利进行的必要条件.纵观目前的IT行业,能够流利的与国外客户英文口语交流的程序员占比并不是很高.要想去国际接轨,语言这 ...

  9. spice客户端android,Compile Android Spice(aSpice)

    Before following the BUILDING instruction in the repo, you need download android-ndk-r9d, or else yo ...

最新文章

  1. Java设计模式(一):策略设计模式
  2. 【每周CV论文推荐】 初学深度学习单张图像三维人脸重建需要读的文章
  3. 宜昌远安谋定功能性-农业大健康·万祥军:绿色和谐新路
  4. SourceTree查找Github修改记录的技巧
  5. 第一章计算机网络概述答案,第一章 计算机网络概述[3]
  6. Java与C++有何区别呢?请看以下几点就明白了……
  7. php memcached 方法,php操作使用Memcached常用方法代码和例子大全
  8. SpringCloud学习笔记009---杂七杂八003:spring的@Transactional注解详细用法
  9. 投资五大基本法则,助你在理财投资路上走得更平稳顺利
  10. 果蔬连连看java源代码_《基于Qt的连连看游戏的设计》-毕业论文.doc
  11. PHP中define定义的常量如何在smarty模板调用
  12. Cgroup学习之——Ubuntu下交叉编译ARM平台libcgroup工具
  13. bootbox api
  14. 不低调的巨人,史玉柱
  15. 蓝带 拱桥 区别_蓝带
  16. fail2ban 的使用
  17. 网络舆情风险点排查工作实施方案
  18. 为什么很多商家开始搭建自己的小程序商城?
  19. Jquery基础学习之-入门
  20. 中国企业级HTML5产业联盟成立 巨头联手共建新移动生态

热门文章

  1. python爬虫 - 猿人学第十九题突破ja3指纹验证
  2. 惠普P9500用创新去争夺高端存储市场
  3. 太平洋电信新一代SD-WAN打造敏捷IT架构
  4. 蚂蚁全媒体中心刘鑫炜解答:产品软文推广怎么写,如何写好软文
  5. SAP中成本估算没有找到工艺路线消息处理实例
  6. 【教程】使用U盘制作Win10系统启动盘(重装系统准备工作)
  7. opencv识别数码管数字
  8. [附源码]SSM计算机毕业设计高校教材订购系统JAVA
  9. 基于全局和局部对比自监督学习的高分辨率遥感图像语义分割day3 - 网络结构
  10. STM32H7系列使用硬件IIC读写EEPROM(HAL库配置源码)