Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6628247
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: Android平台

2015-11-16 11:27:01

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

参考页面: 

1.   

2.  


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

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 :



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 访问权限 :

插上小米后: 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 

解法一:  参考: 

  然后执行

$ curl "" > ~/bin/repo $ chmod a+x ~/bin/repo
解法二 : 
 $ 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天,最后是看到这个帖子,受到启发 

具体的解决方法是: 使用 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 : 

           fetch="https://android.googlesource.com"    
           review="android-review.googlesource.com" />  


             fetch=""
           review="review.cyanogenmod.org" />  


             fetch="ssh://git@github.com" />


             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 accessing/platform/cts.git/info/refs

Fetching projects:   1% (5/456)  error: The requested URL returned error: 406 while accessing /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 文件,找到

 

           fetch=".."

           review="review.cyanogenmod.org" />

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

阅读(2542) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~