Android版本下载以及切换

http://blog.chinaunix.net/uid-20665047-id-3758327.html

1:下载android主线分支

repo init -u https://android.googlesource.com/platform/manifest

 

2:下载android其它分支

repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

 

3;查看android分支版本号

git --git-dir .repo/manifests/.git/ branch -a

 

4:查看android当前版本号

    在build/core/version_defaults.mk文件中查看PLATFORM_VERSION即可。

 

5:切换android分支

    4.1 初始化repo客户端到某一分支(以android-4.0.3_r1为例)

        repo init -b android-4.0.3_r1

    可以在目录 .repo/manifest.xml中查看repo客户端是在哪个分支上。

    4.1 同步代码

       repo sync

6:创建自己的本地分支

    6.1 构造本地分支

       repo start myandroid4.0.3 --all ,分支名称为myandroid4.0.3

    6.2检出到自己创建的分支上

       repo checkout myandroid4.0.3 或

       repo checkout myandroid4.0.3 origin/android-4.0.3_r1

7:下载android linux kernel代码

       查看https://android.googlesource.com/

8:如何获得指定版本的Linux内核

        在下载目录下执行:

git checkout remotes/origin/android-2.6.29  

(以android-2.6.29为例)

9:查看repo可切换的分支
      cd .repo/manifests
      git branch -a | cut -d / -f 3

 

出错问题解决:

1:执行repo sync时出现

fatal: '../platform/abi/cpp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Cannot fetch platform/abi/cpp

------》在.repo目录下的manifest.xml里找到fetch属性改成fetch= "git://Android.git.linaro.org/ ",或 "http://android.googlesource.com”。

:

 

repo工具是git工具的封装,下载单个project时使用git,下载所有android源码时使用repo工具。用法都是一样的。



看着Google的教程,下载了android的源代码。

默认分支是android-4.0.1_r1.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

代码下载完成了,也编译通过,并在虚拟机中运行了。

最大的问题是:
如何将代码的版本从4.0.1降到2.3.6呢?

网上找一个切换分支的文档,就是不成功。
疑问:是不是切换分支,就可以更改android代码的版本?

文档如下:
查看可切换的分支 
cd .repo/manifests 
git branch -a | cut -d / -f 3 
 
 
以  gingerbread-release 分支为例 
repo init -b gingerbread-release  
repo sync (not needed if your local copy is up to date) 
repo start gingerbread-release --all  
查看当前的分支 
repo branches


在android源代码的根目录下运行这句话:
repo init -b gingerbread-release 

出错,
信息如下

yu@yu-laptop:~/WORKING_DIRECTORY$ repo init -b gingerbread-release

... A new repo command ( 1.18) is available.
... You should upgrade soon:

    cp /home/yu/WORKING_DIRECTORY/.repo/repo/repo /home/yu/bin/repo

Traceback (most recent call last):
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/main.py", line 408, in 
    _Main(sys.argv[1:])
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/main.py", line 388, in _Main
    result = repo._Run(argv) or 0
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/main.py", line 138, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/subcmds/init.py", line 322, in Execute
    self._SyncManifest(opt)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/subcmds/init.py", line 192, in _SyncManifest
    m.MetaBranchSwitch(opt.manifest_branch)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/project.py", line 2151, in MetaBranchSwitch
    self.Sync_LocalHalf(syncbuf)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/project.py", line 1041, in Sync_LocalHalf
    lost = self._revlist(not_rev(revid), HEAD)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/project.py", line 1816, in _revlist
    return self.work_git.rev_list(*a, **kw)
  File "/home/yu/WORKING_DIRECTORY/.repo/repo/project.py", line 1961, in rev_list
    p.stderr))
error.GitError: manifests rev-list ('^12303f87b9f90c07bf4aec4c4353ba514ee70c8a', 'HEAD', '--'): fatal: bad revision 'HEAD'


求过各位大侠不吝指点。

猜你喜欢

转载自blog.csdn.net/think_ycx/article/details/78633021
今日推荐