Mac 上下载编译Android源码(AOSP)

2017-06-14  本文已影响1231人  HanlyJiang

记录了在Mac10.12.5 系统上下载清华和科大源的AOSP 源码,并编译适用于Nexus5 的 Android 6.0.1 系统的过程。

环境

MAC 10.12.5
准备编译Android  6.0 版本,因为我有Nexus5,而N5 二进制包Google 提供的最新版本如下: 
M4B30Z  android-6.0.1_r77

下载源码

repo 下载

    mkdir ~/bin
    PATH=~/bin:$PATH
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    ## 如果上述 URL 不可访问,可以用下面的:
    ## curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

清华大学Android 底包下载:

wget https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
    tar xf aosp-latest.tar

源码同步

重新初始化一下,更改分支:

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

更改成科大源:(更改文件 .repo/manifests.git/config)
https://aosp.tuna.tsinghua.edu.cn/platform/manifest 替换成 git://mirrors.ustc.edu.cn/aosp/platform/manifest

同步源码:
repo sync

二进制文件下载

Nexus5 二进制文件下载: https://developers.google.com/android/drivers#hammerhead
之后解压到源码树根目录,然后执行自解压脚本

编译环境配置

编译

由于之前有解压二进制包,先执行:
make clobber
然后
```source build/envsetup.sh
lunch

选择 `19. aosp_hammerhead-userdebug`
编译:`make` 
    
    
## 编译成功
    Creating filesystem with parameters:
        Size: 1073741824
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 8192
        Inode size: 256
        Journal blocks: 4096
        Label: system
        Blocks: 262144
        Block groups: 8
        Reserved block group size: 63
    Created filesystem with 1704/65536 inodes and 105718/262144 blocks
    Install system fs image: out/target/product/hammerhead/system.img
    out/target/product/hammerhead/system.img+out/target/product/hammerhead/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=1096212480 blocksize=135168 total=417841026 reserve=11083776
    
    \e[0;32m#### make completed successfully (01:50:38 (hh:mm:ss)) ####\e[00m

## 镜像刷机
        adb reboot fastboot
        cd out/target/product/hammerhead/
        fastboot flash boot boot.img
        fastboot flash system system.img
        fastboot reboot


上一篇 下一篇

猜你喜欢

热点阅读