Android版本下載以及切換之 git使用

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'


求過各位大俠不吝指點。

發佈了5 篇原創文章 · 獲贊 12 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章