准备工作:源码下载与编译

    xiaoxiao2021-03-25  90

    准备工作:源码下载与编译

    作者: 郭孝星 邮箱: guoxiaoxingse@163.com 博客: http://blog.csdn.net/allenwells 简书: http://www.jianshu.com/users/66a47e04215b/latest_articles

    关于作者

    郭孝星,非著名程序员,代码洁癖患者,爱编程,好吉他,喜烹饪,爱一切有趣的事物和人。

    关于文章

    作者的文章会同时发布在Github、与简书上, 文章顶部也会附上文章的Github链接。如果文章中有什么疑问也欢迎发邮件与我交流, 对于交流 的问题, 请描述清楚问题并附上代码与日志, 一般都会给予回复。如果文章中有什么错误, 也欢迎斧正。如果你觉得本文章对你有所帮助, 也欢迎去 star文章, 关注文章的最新的动态。另外建议大家去Github上浏览文章,一方面文章的写作都是在Github上进行的,所以Github上的更新是最及时 的,另一方面感觉Github对Markdown的支持更好,文章的渲染也更加美观。

    文章目录:https://github.com/guoxiaoxing/android-open-source-project-analysis/blob/master/README.md 官方地址:https://source.android.com/index.html 清华大学开源软件镜像站:https://mirror.tuna.tsinghua.edu.cn/help/AOSP/

    源码版本

    android-7.1.1_r1

    电脑环境

    创建区分大小写磁盘

    打开磁盘工具

    创建空白映像

    设置区分大小写

    下载repo工具

    mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo

    如果你没有翻墙,可以使用清华大学的repo镜像:https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/

    下载完成后将bin/repo打开,将里面的REPO_URL改成清华大学的镜像:

    https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

    下载源码

    1 建立工作目录

    mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY $ git config --global user.name "Your Name" $ git config --global user.email "you@example.com"

    2 初始化仓库

    repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest

    如果需要某个特定的Android版本,可以在后面指定版本号。

    Android系统各版本号:https://source.android.com/source/build-numbers.html#source-code-tags-and-builds

    repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1

    同步源码树,开始下载源码,如果后续下载中断,也可以重复执行这个命令。

    repo sync

    源码的下载会经常中断,我们可以写一个脚本自动repo sync,保存成repo.sh,放到WORKING_DIRECTORY目录下

    #!/bin/bash #FileName jkYishon.sh PATH=~/bin:$PATH repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r1 repo sync while [ $? = 1 ]; do echo "================sync failed, re-sync again =====" sleep 3 repo sync done

    配置可执行权限,运行即可。

    chmod 777 repo.sh ./repo.sh

    开始下载

    下载完成

    源码目录

    转载请注明原文地址: https://ju.6miu.com/read-14043.html

    最新回复(0)