zoukankan      html  css  js  c++  java
  • 下载CM11.0 Android 源码过程与错误解决

    http://blog.csdn.net/libelosophy/article/details/22997805

    参考页面: 

    1.  Setting up a linux build environment 

    2.  Downloading and Building


    在下载和编译之前,检查是否符合条件:

    1). Linux 或者 Mac 系统 。 如果在Windows 上使用虚拟机,则需要至少16G 的RAM/SWAP 和 30G 的 磁盘。

    2). 编译2.3 及以上要64位系统。 (head -n 1 /etc/issue 我使用的 Ubutnu 12.04.4 LTS )

    3). 30G 磁盘-- single build ; 100G 磁盘 --full build  (  我的 可用空间有140G)

    4). Python 2.6-2.7 (Ubutnu 自带 2.7.3)

    5). GNU Make 3.8.1 - 3.8.2  (目前还没有)

    6). JDK 7 -- 用来编译最新的 AOSP  (我的 jdk6 7 都有了)

        JDK 6 -- Gingerbread(2.3.x) 到 KitKat(4.4) 

        JDK 5 -- 2.3 以下

    7). Git 1.7 或更新


    --------------------------------------------------------------------------------------------------------------------------------


    1) 安装JDK :

    sun jdk :http://www.oracle.com/technetwork/java/javase/archive-139210.html



    2) 安装 需要的包(12.04) 

     $ sudo apt-get install git gnupg flex bison gperf build-essential     zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev     libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386     libgl1-mesa-dev g++-multilib mingw32 tofrodos     python-markdown libxml2-utils xsltproc zlib1g-dev:i386
     $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so


    3) 配置USB 访问权限 :http://source.android.com/source/initializing.html#setting-up-a-linux-build-environment

    插上小米后: lsusb 下面右一行 Bus 001 Device 005: ID 18d1:9025 Google Inc.

           

    
    

     $ sudo touch /etc/udev/rules.d/51-android-rules

     $ sudo gedit /etc/udev/rules.d/51-android-rules

    添加 : 

          SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="9025", MODE="0600", OWNER="hanly"


    4) 设置ccache (加快编译速度尤其是 有多个编译时)

     在 .bashrc 中添加

     $ export USE_CCACHE=1
     

    --------

    5 下载源码:

    要安装有 repo

    $ mkdir ~/bin
    $ PATH=~/bin:$PATH  ;这个最好是加入到~/.bashrc 中,然后重新开一个终端
    $ [错误1]curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo   ;【20140508】这个又可以了 $ chmod a+x ~/bin/repo


    [错误1] 

    curl 那条行不通,报错  0curl: (7) couldn't connect to host 

    解法一:  参考: http://www.miui.com/thread-1540431-1-1.html 

      然后执行

    $ curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo $ chmod a+x ~/bin/repo
    解法二 : https://code.google.com/p/git-repo/wiki/Source?tm=4
     $ git clone https://gerrit.googlesource.com/git-repo ~/bin/git-repo
     $ cp ~/bin/git-repo/repo ~/bin/repo



    --------- 参考 :link - ----------

    6. 下载源码 :

    $ mkdir -p ~/android/system 
    $ cd ~/android/system/   ; 先不要执行下面的 $ [错误2]repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0  ;


    $ repo sync

    [错误2] :

    在这个地方纠结了2天,最后是看到这个帖子,受到启发  link

    具体的解决方法是: 使用 https 初始化 repo

    1.  直接使用 https 初始化,如下,然后看 修改 manifest.xml 文件

    $ repo init -u https://github.com/CyanogenMod/android.git -b cm-11.0 

    2.  如果已经使用 如下语句 初始化,并下载了部分代码,可以修改 manifest.xml 文件和 manifests.git/config 文件 后再 repo sync

    $ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0 


    修改: 

    然后检查并修改 .repo/manifest.xml : 

    <remote  name="aosp"  
               fetch="https://android.googlesource.com"    
               review="android-review.googlesource.com" />  


      <remote  name="github"
               fetch="https://github.com"
               review="review.cyanogenmod.org" />  <!-- fetch 有可能是 .. ,如果是就改过来,另外如果是 git: ,则改成 https:  -->


      <remote  name="private"
               fetch="ssh://git@github.com" />


      <default revision="refs/heads/cm-11.0"
               remote="github"
               sync-c="true"
               sync-j="4" /> 

    如果是用第二种初始化方法,还需要将 .repo/manifests.git/config 中的git:改成https: 


    然后再 repo sync 就很顺畅了, 另外还可一加参数,-j10 ,即同时开10个线程下载。




    ---------------------------------------------------------------------------------------------------------------------------------

    下面是之前遇到的一些错误,如果 可以同步代码就不用看了。

    1.  android.googlesource.com  

    Initializing project platform/cts ...

    error: Failed to connect to 2404:6800:4005:c00::52:Network is unreachable while accessinghttps://android.googlesource.com/platform/cts.git/info/refs

    Fetching projects:   1% (5/456)  error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/cts.git/info/refs

    fatal: HTTP request failed

    error: Cannot fetch platform/cts


    ping  android.googlesource.com 得到 ip 加入到hosts (sudo gedit /etc/hosts )

    74.125.128.82 android.googlesource.com



    2 . 这个不算错误,因为源码比较大,而中途不知到会出现什么网络问题一部小心就断了, 所以可以写个脚本使失败的时候自动重新执行。


    #!/bin/bash

    echo " ************************************************************** “

    echo  "                              start sync source code " 

    repo sync 

    while  [  $? = 1 ]  ;  do 

    echo   " ----------------------- restart sync ------------------ "

    repo sync

    done


    3 .  

    Initializing project CyanogenMod/android_abi_cpp ...

    fatal: '../CyanogenMod/android_abi_cpp.git' does not appear to be a git repository

    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights

    and the repository exists.

    error: Cannot fetch CyanogenMod/android_abi_cpp

    编辑 ~/android/system/.repo中的 manifest.xml 文件,找到

     <remote  name="github"

               fetch=".."

               review="review.cyanogenmod.org" />

    将 其中的 fetch=".."  改成  fetch="https://github.com" ,因为 ../CyanogenMod/android_abi_cpp.git 实际想找的是 https://github.com/CyanogenMod/android_abi_cpp.git

    <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
    阅读(112) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~
    评论热议
  • 相关阅读:
    spring入门-day01
    HTML概述
    day21-基础加强
    iptables
    25个iptables常用示例
    Linux安全调优1:CentOS防火墙的设置与优化
    sessionStorage 的数据会在同一网站的多个标签页之间共享吗?这取决于标签页如何打开
    JavaScript reduce() 方法
    classList属性和className的区别
    NPM 学习笔记整理
  • 原文地址:https://www.cnblogs.com/ztguang/p/12649235.html
Copyright © 2011-2022 走看看