在这里插入图片描述



一、Android内核源码下载

国内的镜像

git clone https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish.git

git branch
git branch -a
git checkout -b 2.6.29 remotes/origin/android-goldfish-2.6.29

android-goldfish-3.4内核源码

二、Android源码下载

    AOSP 是 Android Open Source Project 的缩写。

git 常用命令总结
git 远程仓库相关的操作

# 查看 remote.origin.url 配置项的值
git config --list 

Android9.0之前代码在线查看地址:http://androidxref.com/
Android9.0之后代码在线查看地址:http://aospxref.com/
Android Open Source Project


repo入门
Android 镜像使用帮助 清华源
Git Repo 镜像使用帮助 清华源

# 1
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
# 为了方便可以将其拷贝到你的PATH里。

# 2
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
# repo的运行过程中会尝试访问官方的git源更新自己,如果想使用tuna的镜像源进行更新,
# 可以将如下内容复制到你的~/.bashrc里

# 3
# 建立工作目录:
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY

# 初始化仓库:
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest

# 如果需要某个特定的 Android 版本(列表):
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-4.0.1_r1
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-2.3.1_r1

# 同步源码树(以后只需执行这条命令来同步):
repo sync

repo init出现Unable to fully sync the tree


清华源 manifest
android源码下载及soong build目录结构解析

  1. 下载源码目录信息
# 1 下载版本目录
mkdir Android
cd Android
git clone git://http://mirrors.ustc.edu.cn/aosp/platform/manifest

# 2 
cd manifest
git tag #(列出安卓版本号)
git checkout android-5.1.1_r18 ##checkout你想下载的版本号
# checkout之后,manifest/default.xml文件中记录的就是android5.1系统各个模块的路径
  1. 编写python下载文件download.py
import xml.dom.minidom  
import os  
from subprocess import call  

#downloaded source path  
rootdir = "/home/xx/learnAndroid/source/2.3.1"  

#git program path  
#git = "C:/sun/library/git/Git/bin/git.exe"  

dom = xml.dom.minidom.parse("/home/xx/learnAndroid/source/anGit/manifest/default.xml")  
root = dom.documentElement  

# prefix = git + " clone https://android.googlesource.com/"  
prefix = "git clone https://aosp.tuna.tsinghua.edu.cn/"  
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:", cmd)
    # call(cmd)
    result = os.popen(cmd)
    print(result.read())

Python调用系统命令的四种方法详解

  1. 执行python文件开始下载
cmd

python download.py

史上最简最全,Android AOSP源码阅读+编译环境这一篇就够了
android:自己动手编译Android源码(超详细)
Android 系统源码下载及编译

三、API 及源码阅读

怎么利用Android Studio查看Android-SDK源码

   

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐