The steps for download android source code

2024-09-04 22:48

本文主要是介绍The steps for download android source code,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

The steps for download android source code. Except for the git tool, all the other steps is for both Windows and Linux.


以下描述是Windows上的操作步骤,其实windows和Linux上面的执行过程没有多大差别,仅在于git安装、Python脚本改成和机器上Python版本相一致。文档最后给出了Linux上获取代码时,执行的所有命令序列。


All the content is referece the link: Windows下载Android源码

1. start git-shell:
2. enter the android folder
3. git clone https://android.googlesource.com/platform/manifest.git
   This will create the manifest directory, and clone the ./manifest/.git directory.
   
hp@HP-PC /e/android
$ git clone https://android.googlesource.com/platform/manifest.git
Cloning into 'manifest'...
remote: Counting objects: 106, done
remote: Finding sources: 100% (106/106)
remote: Total 1030 (delta 144), reused 1030 (delta 144)
Receiving objects: 100% (1030/1030), 895.45 KiB | 498.00 KiB/s, done.
Resolving deltas: 100% (144/144), done.hp@HP-PC /e/android
$



4. switch to the manifest directory that just cloned.
   And list all the tags by 'git tag'.
   
hp@HP-PC /e/android
$ ls
a.txt       android_src_download_steps.txt  download_src_new.py  recovery-si
android-si  download_src.py                 manifest             srchp@HP-PC /e/android
$ cd manifesthp@HP-PC /e/android/manifest (master)
$ git tag
android-1.6_r1.1_
.......
android-4.3_r3.1
android-4.4.1_r1
android-4.4.2_r1
android-4.4.2_r2
android-4.4_r1
android-4.4_r1.1
android-4.4_r1.2
android-cts-2.2_r8
android-cts-2.3_r10
android-cts-2.3_r11
android-cts-2.3_r12
android-cts-4.0.3_r1
android-cts-4.0.3_r2
android-cts-4.0_r1
android-cts-4.1_r1
android-cts-4.1_r2
android-cts-4.2_r2
android-cts-4.4_r1
android-cts-verifier-4.0.3_r1
android-cts-verifier-4.0_r1
android-sdk-4.0.3-tools_r1
android-sdk-4.0.3_r1
android-sdk-4.4.2_r1
android-sdk-adt_r16.0.1
android-sdk-adt_r20
android-sdk-support_r11hp@HP-PC /e/android/manifest (master)
$



5. check out the android version
hp@HP-PC /e/android/manifest (master)
$ git checkout android-4.4.2_r2
Note: checking out 'android-4.4.2_r2'.You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:git checkout -b new_branch_nameHEAD is now at 1a5a541... Update manifest for android-4.4.2_r2hp@HP-PC /e/android/manifest ((android-4.4.2_r2))
$



6. Understand the manifest/default.xml, and write a python script file
   to generate a git-clone file.
   Then execute the .py file, or all the git-clone will start automatically.
   ATTENTION PLS: a. There must be 40G in the disk. b. All the clone will spend many many hours.
   
hp@HP-PC /e/android
$ ls
a.txt       android_4.4.2_r2                download_src.py  recovery-si
android-si  android_src_download_steps.txt  manifest         srchp@HP-PC /e/android
$ python download_src.py   
C:/Program Files/Git/bin/git.exe clone http://android.googlesource.com/platform/
build.git
Cloning into 'build'...
remote: Sending approximately 23.91 MiB ...
remote: Counting objects: 957, done
remote: Finding sources: 100% (170/170)
Receiving objects:  87% (45093/51754), 9.44 MiB | 210.00 KiB/s   


7. here is the python file as the link that I have referenced.

import xml.dom.minidom
import os
from subprocess import call#downloaded source path
# if the dir does not exist, it will be created autoomatically as below.
rootdir = "E:/android/android_4.4.2_r2"#git program path
git="C:/Program Files/Git/bin/git.exe"dom = xml.dom.minidom.parse("E:/android/manifest/default.xml")
root = dom.documentElementprefix = git + " clone http://android.googlesource.com/"
suffix = ".git"if not os.path.exists(rootdir):os.mkdir(rootdir)for node in root.getElementsByTagName("project"):os.chdir(rootdir)d = node.getAttribute("path")last = d.rfind("/")if last != -1:d = rootdir + "/" + d[:last]if not os.path.exists(d):os.makedirs(d)os.chdir(d)cmd = prefix + node.getAttribute("name") + suffixprint cmdcall(cmd)

附:Linux上下载Android源码的执行命令:

test@myhost /home/test/Android % git clone https://android.googlesource.com/platform/manifest.git
正克隆到 'manifest'...
error: Failed to connect to 2404:6800:4005:c00::52: Network is unreachable while accessing https://android.googlesource.com/platform/manifest.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
129 test@myhost /home/test/Android % git clone https://android.googlesource.com/platform/manifest.git
正克隆到 'manifest'...
remote: Counting objects: 106, done
remote: Finding sources: 100% (106/106)
remote: Total 1030 (delta 144), reused 1030 (delta 144)
接收对象中: 100% (1030/1030), 895.45 KiB | 416 KiB/s, done.
处理 delta 中: 100% (144/144), done.
test@myhost /home/test/Android % ll
总用量 212
-rw-r--r-- 1 test users      2  3月  2 14:34 android_download_source_code_steps.txt
drwxr-xr-x 3 test users   4096  3月  2 14:36 manifest/
-rw-r--r-- 1 test users  35672  3月  1 14:25 python_files.png
drwxr-xr-x 3 test users   4096  3月  1 14:31 Python_Src/
-rw-r--r-- 1 test users 164603  3月  1 16:08 using_authentication.png
test@myhost /home/test/Android % ll ./manifest
总用量 164
-rw-r--r-- 1 test users 21759  3月  2 14:36 base-for-3.0-gpl.xml
-rw-r--r-- 1 test users 22323  3月  2 14:36 base-for-3.1-gpl.xml
-rw-r--r-- 1 test users 23221  3月  2 14:36 base-for-3.2-gpl.xml
-rw-r--r-- 1 test users 45492  3月  2 14:36 base-for-4.2-gpl.xml
-rw-r--r-- 1 test users 40984  3月  2 14:36 default.xml
test@myhost /home/test/Android % cd manifest
test@myhost /home/test/Android/manifest (git)-[master] % git tag
android-1.6_r1.1_
..........
android-4.4.1_r1
android-4.4.2_r1
android-4.4.2_r2
android-4.4_r1
android-4.4_r1.1
android-4.4_r1.2
.................
android-sdk-support_r11
test@myhost /home/test/Android/manifest (git)-[master] % git checkout android-4.4.2_r2
Note: checking out 'android-4.4.2_r2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD 目前位于 1a5a541... Update manifest for android-4.4.2_r2
test@myhost /home/test/Android/manifest (git)-[android-4.4.2_r2] % cd ..
test@myhost /home/test/Android % ll
总用量 216
-rw-r--r-- 1 test users      2  3月  2 14:34 android_download_source_code_steps.txt
-rw-r--r-- 1 test users    855  3月  2 14:41 download_android_src.py
drwxr-xr-x 3 test users   4096  3月  2 14:38 manifest/
-rw-r--r-- 1 test users  35672  3月  1 14:25 python_files.png
drwxr-xr-x 3 test users   4096  3月  1 14:31 Python_Src/
-rw-r--r-- 1 test users 164603  3月  1 16:08 using_authentication.png
test@myhost /home/test/Android % cat download_android_src.py
#! /usr/bin/env python
import xml.dom.minidom  
import os  
from subprocess import call  
#downloaded source path  
# if the dir does not exist, it will be created autoomatically as below.  
rootdir = "/home/test/Android/android_4.4.2_r2"  
#git program path  
git="git"  
dom = xml.dom.minidom.parse("/home/test/Android/manifest/default.xml")  
root = dom.documentElement  
prefix = git + " clone http://android.googlesource.com/"  
suffix = ".git"  
if not os.path.exists(rootdir):  
os.mkdir(rootdir)  
for node in root.getElementsByTagName("project"):  
os.chdir(rootdir)  
d = node.getAttribute("path")  
last = d.rfind("/")  
if last != -1:  
d = rootdir + "/" + d[:last]  
if not os.path.exists(d):  
os.makedirs(d)  
os.chdir(d)  
cmd = prefix + node.getAttribute("name") + suffix  
print cmd  
call(cmd, shell=True)   
test@myhost /home/test/Android % ll
总用量 216
-rw-r--r-- 1 test users      2  3月  2 14:34 android_download_source_code_steps.txt
-rw-r--r-- 1 test users    879  3月  2 14:42 download_android_src.py
drwxr-xr-x 3 test users   4096  3月  2 14:38 manifest/
-rw-r--r-- 1 test users  35672  3月  1 14:25 python_files.png
drwxr-xr-x 3 test users   4096  3月  1 14:31 Python_Src/
-rw-r--r-- 1 test users 164603  3月  1 16:08 using_authentication.png
test@myhost /home/test/Android % chmod +x download_android_src.py
test@myhost /home/test/Android % ll
总用量 216
-rw-r--r-- 1 test users      2  3月  2 14:34 android_download_source_code_steps.txt
-rwxr-xr-x 1 test users    879  3月  2 14:42 download_android_src.py*
drwxr-xr-x 3 test users   4096  3月  2 14:38 manifest/
-rw-r--r-- 1 test users  35672  3月  1 14:25 python_files.png
drwxr-xr-x 3 test users   4096  3月  1 14:31 Python_Src/
-rw-r--r-- 1 test users 164603  3月  1 16:08 using_authentication.png
1 test@myhost /home/test/Android % python --version
Python 2.7.3
test@myhost /home/test/Android % ./download_android_src.py
git clone http://android.googlesource.com/platform/build.git
正克隆到 'build'...
remote: Sending approximately 23.92 MiB ...
remote: Counting objects: 963, done
remote: Finding sources: 100% (176/176)


这篇关于The steps for download android source code的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/1137250

相关文章

使用nohup和--remove-source-files在后台运行rsync并记录日志方式

《使用nohup和--remove-source-files在后台运行rsync并记录日志方式》:本文主要介绍使用nohup和--remove-source-files在后台运行rsync并记录日... 目录一、什么是 --remove-source-files?二、示例命令三、命令详解1. nohup2.

Android NDK版本迭代与FFmpeg交叉编译完全指南

《AndroidNDK版本迭代与FFmpeg交叉编译完全指南》在Android开发中,使用NDK进行原生代码开发是一项常见需求,特别是当我们需要集成FFmpeg这样的多媒体处理库时,本文将深入分析A... 目录一、android NDK版本迭代分界线二、FFmpeg交叉编译关键注意事项三、完整编译脚本示例四

Android与iOS设备MAC地址生成原理及Java实现详解

《Android与iOS设备MAC地址生成原理及Java实现详解》在无线网络通信中,MAC(MediaAccessControl)地址是设备的唯一网络标识符,本文主要介绍了Android与iOS设备M... 目录引言1. MAC地址基础1.1 MAC地址的组成1.2 MAC地址的分类2. android与I

Android 实现一个隐私弹窗功能

《Android实现一个隐私弹窗功能》:本文主要介绍Android实现一个隐私弹窗功能,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 效果图如下:1. 设置同意、退出、点击用户协议、点击隐私协议的函数参数2. 《用户协议》、《隐私政策》设置成可点击的,且颜色要区分出来res/l

Android实现一键录屏功能(附源码)

《Android实现一键录屏功能(附源码)》在Android5.0及以上版本,系统提供了MediaProjectionAPI,允许应用在用户授权下录制屏幕内容并输出到视频文件,所以本文将基于此实现一个... 目录一、项目介绍二、相关技术与原理三、系统权限与用户授权四、项目架构与流程五、环境配置与依赖六、完整

Android 12解决push framework.jar无法开机的方法小结

《Android12解决pushframework.jar无法开机的方法小结》:本文主要介绍在Android12中解决pushframework.jar无法开机的方法,包括编译指令、框架层和s... 目录1. android 编译指令1.1 framework层的编译指令1.2 替换framework.ja

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

Android实现定时任务的几种方式汇总(附源码)

《Android实现定时任务的几种方式汇总(附源码)》在Android应用中,定时任务(ScheduledTask)的需求几乎无处不在:从定时刷新数据、定时备份、定时推送通知,到夜间静默下载、循环执行... 目录一、项目介绍1. 背景与意义二、相关基础知识与系统约束三、方案一:Handler.postDel

Android使用ImageView.ScaleType实现图片的缩放与裁剪功能

《Android使用ImageView.ScaleType实现图片的缩放与裁剪功能》ImageView是最常用的控件之一,它用于展示各种类型的图片,为了能够根据需求调整图片的显示效果,Android提... 目录什么是 ImageView.ScaleType?FIT_XYFIT_STARTFIT_CENTE

Android实现在线预览office文档的示例详解

《Android实现在线预览office文档的示例详解》在移动端展示在线Office文档(如Word、Excel、PPT)是一项常见需求,这篇文章为大家重点介绍了两种方案的实现方法,希望对大家有一定的... 目录一、项目概述二、相关技术知识三、实现思路3.1 方案一:WebView + Office Onl