Android源码编译

!!!原创地址:http://write.blog.csdn.net/mdeditor#!postId=49638397
   欢迎大家评论交流,如有问题,可以留言!!!

Ubuntu下编译Android 4.4.2和5.1.1的源码

编译环境

Ubuntu版本,查看命令:
  cat /etc/issue   或者   sudo lsb_release -a
  查看内核版本号,命令:
  uname -r
  我的环境:
    Ubuntu版本:Ubuntu 14.04.3 LTS;内核版本:3.16.0-51-generic

JDK版本问题

  442版本源码需要Sun JDK1.6
  511版本源码需要openjdk1.7
  下载安装完成后,需要修改环境变量,使用source命令使其生效。
  使用java -version来查看版本是否正确

下载源码

  方法一:到Android的官网下载源码
    此处暂时不介绍,太难下载
    参见链接:http://source.android.com/source/downloading.html

  方法二:下载其他来源的源码
    我编译的源码地址:
      442:http://pan.baidu.com/s/1kTMtSph 密码: vja3
      511: http://pan.baidu.com/s/1dDc4Wmd 密码: uy4p
    解压下载的源码压缩包,以442版本为例,511版本过程相同
    我的解压路径:~/learning/android442

编译前准备

  1、使用sudo apt-get install安装如下内容:
    bison
    g++-multilib
    git
    gperf
    libxml2-utils
    make
    python-networkx
    zlib1g-dev:i386
    zip
    flex
    build-essential
    libncurses5-dev:i386
    libx11-dev:i386
    libreadline6-dev:i386
    mingw32
    tofrodos
    xsltproc
    zlib1g-dev
    lib64z1-dev

  2、在 ~/.bashrc文件中添加:export USE_CCACHE = 1
    输入命令source ~/.bashrc 使其生效

编译源码

  cd ~/learning/android442
  注意:之后所有操作都在android442目录下

  输入命令:prebuilts/misc/linux-x86/ccache/ccache -M 50G
   说明: a、ccache是一个可执行文件
     b、-M 50G 表示设置50G大小的空间作为缓存,大小可调整
这里写图片描述

  导入编译android源码需要的环境变量
  source build/envsetup.sh
这里写图片描述

  输入:lunch(导入了envsetup.sh才能使用)    并选择 1
这里写图片描述

  进行编译,输入 make -j4 (4为线程数,可以根据自己电脑配置修改)
这里写图片描述

  编译完成:
这里写图片描述

常见问题

  错误1:
  这里写图片描述
  解决方案:sudo apt-get install flex

  错误2:
  这里写图片描述
  解决方案:sudo apt-get isntall 如下:build-essential、libncurses5-dev:i386、libx11-dev:i386、libreadline6-dev:i386、g++-multilib、mingw32、tofrodos、xsltproc

参考链接

  在Ubuntu上下载、编译和安装Android最新源代码:
  http://blog.csdn.net/luoshengyang/article/details/6559955
  Android源码编译环境:http://source.android.com/source/initializing.html
  Android源码下载:http://source.android.com/source/downloading.html
  Android源码编译:http://source.android.com/source/building.html
  编译常见问题:
  http://blog.csdn.net/ithomer/article/details/
  http://blog.sina.com.cn/s/blog_493667730101qze1.html
  http://blog.csdn.net/ithomer/article/details/6977386
  ubuntu14.04的error while loading shared libraries: libz.so.1:
  http://blog.csdn.net/stephen_yu/article/details/45645073
  源码编译步骤:
  http://blog.csdn.net/xueerfei008/article/details/17409447
  http://www.cnblogs.com/wanqieddy/archive/2011/07/15/2107375.html
  http://www.cloudchou.com/android/post-276.html
  生成AndroidSDK深入探索:http://blog.csdn.net/alien75/article/details/46745547
  make sdk 出现错误:http://blog.sina.com.cn/s/blog_940a6ced0101h3v4.html
  解决sdk/eclipse/scripts/create_all_symlinks.sh: 第 285 行: cd: tools/base:
  http://blog.sina.com.cn/s/blog_6e5b91c50102vw34.html
  http://www.tqcto.com/article/mobile/137838.html
  编译自己的SDK:http://blog.csdn.net/ilittleone/article/details/10714433

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值