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

使用repo下载google 的android4.4 源码

2014-08-04 16:00 519 查看
使用repo下载google 的android4.4 源码
 参看http://hi.baidu.com/j_key/item/170505ad9efd0037030a4d5d,根据自己的下载过程进行修改了。
 环境:ubuntu12 64 位。
 
1.安装git
sudo apt-get install git-core
 
2.安装curl
sudo apt-get install git-core curl
 
3.安装repo, 通过curl下载repo
google s是这样告诉我们的:curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
但是好像是不能访问
解决方法: http://code.google.com/p/git-repo/downloads/detail?name=repo-1.12 这个链接提供下载repo!
也可以通过下面命令得到:
curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
具体的repo版本可以去查看http://code.google.com/p/git-repo/downloads 页面上的信息,下载那个版本都行。
 
4.修改执行权限
chmod a+x ~/bin/repo
 
5.修改~/bin/repo文件将第五行
问题:
builder56@builder56-desktop:~/google/android_source$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (56) Recv failure: 连接被对端重置
 
解决方法:修改~/bin/repo文件将第五行
REPO_URL='https://gerrit.googlesource.com/git-repo'
改为
REPO_URL='http://gerrit.googlesource.com/git-repo'
 
6.然后向PATH中添加bin路径:
export PATH=$PATH:~/bin
 
使用$PATH 查看该值,看是否添加成功
 
7.新建一个目录,然后进入该目录。
mkdir source
cd source
 
8.执行repo init 创建仓库
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.4_r1   //下载android-2.3.4_r1android-2.3.4_r1
这一步大概有一分多钟就完成了。
如果需要下载其他分支将android-2.3.4_r1 改成其他分支名称就可以了。分支名称请在https://android.googlesource.com/platform/manifest/+refs 里面查看branch
 
比如下载android-4.4_r1.2 
repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1.2
 
9.执行repo sync 进行同步
出现问题:
builder56@builder56-desktop:~/google/android_source/.repo$ repo sync
 
... A new repo command ( 1.18) is available.
... You should upgrade soon:
 
    cp /home/builder56/google/android_source/.repo/repo/repo /home/builder56/bin/repo
解决方法:执行命令  cp /home/builder56/google/android_source/.repo/repo/repo /home/builder56/bin/repo
 
 9.1问题Network is unreachable while accessing  https://android.googlesource.com/platform/development/info/refs

解决方法:sudo gedit /etc/hosts host 文件

添加内容:

74.125.237.1   dl-ssl.google.com 

74.125.71.82 www.googlesource.com   

74.125.31.82 android.googlesource.com  

203.208.46.172 cache.pack.google.com   

59.24.3.173cache.pack.google.com

 

注:

google source 的ip 是会改动的,那我们如何知道当前真实的ip,看了一下google known-issues,具体方法如下:

使用命令:

$ nslookup googlesource.com

$ nslookup android.googlesource.com

 

查看实际ip,将上面得到ip地址按照74.125.31.82 android.googlesource.com 格式加到/etc/hosts. 具体如图:



 

9.2 出现下载过程中,没有断网确一直不动的情况

创建脚本download.sh

 #!/bin/bash     

    echo "======start repo sync======"     

    repo sync     

    while [ $? == 1 ]; do     

    echo "======sync failed, re-sync again======"     

    sleep 3     

    repo sync     

 

    done 

 

chomd a+x download.sh让其可以运行,然后终端输入./download.sh就可以开始下载了,用这一步代替官方文档里的repo sync。当连接不上终端时休息3毫秒然后再自动repo sync,这样就不用一直等着不用下班了。

如果有时间一直等这看,那句直接ctrl+c 取消下载,再输入repo sync. 

 

下载完成,上图:



 

9.3 查看log和分支信息:

分支信息:git --git-dir=.repo/manifests/.git/ branch -a  

log信息:git --git-dir=.repo/manifests/.git/ log

使用git 命令需要目录下面有.git 目录,下载之后的源码里面.git目录就在.repo/manifests/.git/

 

10.编译

由于我工作的电脑jdk 等环境之前已经按照了,所以不需要其他操作了。

10.1:具体可以去看google 的网站。我这里只是写自己的过程。

$ source build/envsetup.sh
[/code]

or
$ . build/envsetup.sh
[/code]
 

然后,执行:make

 

 10.2 jdk 版本太低了,导致AnnotationAccess.java:695: 无法确定 <A>A 的类型参数的错误

libcore/luni/src/main/java/libcore/reflect/AnnotationAccess.java:695: 无法确定 <A>A 的类型参数;对于上限为 A,java.lang.annotation.Annotation 的类型变量 A,不存在唯一最大实例

        return AnnotationFactory.createAnnotation(annotationClass, members);

                                                 ^

解决方法:将默认的jdk 版本改成其他高版本的,这里我使用的是jdk1.6.0_43

查看jdk 版本:java -version

修改默认的jdk 版本:sudo gedit /etc/profile ,然后按照下面的修改(ANDROID_HOME 不管,是sdk 的)

export JAVA_HOME=/home/builder56/software/jdk1.6.0_43

export JRE_HOME=/home/builder56/software/jdk1.6.0_43

export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export ANDROID_HOME=/home/builder56/software/adt-bundle-linux-x86_64-20131030/sdk/platform-tools

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ANDROID_HOME:$PATH

 

接着:source  /etc/profile ,使修改生效,再次使用java -version 查看是否修改成功。

 

 10.3 llvm 报错

external/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:370: error: undefined reference to 'llvm::TargetMachine::resetTargetOptions(llvm::MachineFunction const*) const'

external/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:380: error: undefined reference to 'llvm::BranchProbabilityInfo::ID'

external/llvm/lib/CodeGen/Passes.cpp:409: error: undefined reference to 'llvm::createLowerInvokePass(llvm::TargetMachine const*, bool)'

collect2: error: ld returned 1 exit status

make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libLLVM_intermediates/LINKED/libLLVM.so] 错误 1

 

解决方法:根据我最终的修改发现是repo 的版本问题,请按照google 的要求下载最新的版本,可以完美解决该问题。

 

$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

   

编译完成:上图



 

12.使用最新的launcher3

系统默认编译的是launcher2 

 grep -r "Launcher" build/

 

builder56@builder56-desktop:~/google/android_source4.4$ grep -r "Launcher" build/

build/target/product/large_emu_hw.mk:    Launcher2 \

build/target/product/sdk.mk:Launcher2 \

build/target/product/generic_no_telephony.mk:    Launcher2 \

 

自己增加launcher3 的配置



 

13 配置gitweb

sudo apt-get install gitweb

sudo vi /etc/gitweb.conf 

修改$projectroot为 $projectroot = "/home/builder56/google/android_source4.4";

 
http://192.168.1.104/gitweb/     可以查看具体git 的信息. 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  源码 git repo