您的位置:首页 > 移动开发 > Android开发

Android源码编译

2015-11-04 15:14 531 查看
!!!原创地址: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最新源代码:

  /article/1363578.html

  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:

  /article/8474391.html

  源码编译步骤:

  /article/2057315.html

  /article/4708397.html

  http://www.cloudchou.com/android/post-276.html

  生成AndroidSDK深入探索:/article/1880949.html

  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:/article/2504161.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: