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

相关文章

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

Android里面的Service种类以及启动方式

《Android里面的Service种类以及启动方式》Android中的Service分为前台服务和后台服务,前台服务需要亮身份牌并显示通知,后台服务则有启动方式选择,包括startService和b... 目录一句话总结:一、Service 的两种类型:1. 前台服务(必须亮身份牌)2. 后台服务(偷偷干

Android kotlin语言实现删除文件的解决方案

《Androidkotlin语言实现删除文件的解决方案》:本文主要介绍Androidkotlin语言实现删除文件的解决方案,在项目开发过程中,尤其是需要跨平台协作的项目,那么删除用户指定的文件的... 目录一、前言二、适用环境三、模板内容1.权限申请2.Activity中的模板一、前言在项目开发过程中,尤

Android数据库Room的实际使用过程总结

《Android数据库Room的实际使用过程总结》这篇文章主要给大家介绍了关于Android数据库Room的实际使用过程,详细介绍了如何创建实体类、数据访问对象(DAO)和数据库抽象类,需要的朋友可以... 目录前言一、Room的基本使用1.项目配置2.创建实体类(Entity)3.创建数据访问对象(DAO