23

I'm trying to learn Embedded Android from the book with the same name. And the author suggested working with AOSP gingerbread branch. So I followed to download the source:

$ repo init -u https://android.googlesource.com/platform/manifest.git
-b gingerbread

$ repo sync

But it's taking too long. Also from the output, it seems to me like it's also downloading source code from other branches (I see android-5.....) which is not what I want. I'm wondering if that's the reason why it takes so long.

Has anybody had the same problem? Please give me a suggestion! Thanks!

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
user3011609
  • 331
  • 1
  • 2
  • 3
  • At the time of writing you need about 400GB of disk space to checkout the code and make one build. For additional builds more disk space is required. I'd expect this to grow by 50-100GB per year. But that's just a wild guess. – Forivin Oct 21 '20 at 11:18

4 Answers4

39

AOSP is a multi-gigabyte download so there's not that much you can do. However, passing the -c/--current-branch option to repo sync causes Repo to tell Git to only fetch the branch you really need instead of all branches of each repository. With an old release like Gingerbread this should theoretically be quite beneficial. However, Repo seeds the repositories with Git bundles that it downloads via HTTP, and the bundle files aren't affected by the -c option. Using --no-clone-bundle disables the bundle files. Hence the following Repo command should yield the smallest download:

repo sync -c --no-clone-bundle

(Keep in mind that Gingerbread is a several year old release. It won't work out of the box on a lot of recent hardware.)

Magnus Bäck
  • 11,381
  • 3
  • 47
  • 59
  • 1
    But if you specify a branch (example Marshmallow), shouldn't it not download other branches (nougat, gingerbread) ? For example if you specify the manifest for marshmallow with -b ? – Rahul Iyer Mar 05 '17 at 09:30
  • @KaizerSozay: Yes, that's what I'm trying to say. With `-c` you only download the needed branches. – Magnus Bäck Mar 14 '17 at 07:38
16

You should use this commands:

Example: for my personal AOSP Repo,

repo init --depth=1 -u https://github.com/zawzaww/aosp-android.git -b android-8.1.0

and then,

repo sync  -f --force-sync --no-clone-bundle --no-tags -j$(nproc --all)

You can learn more on my GitHub Repo

akshat
  • 1,219
  • 1
  • 8
  • 24
Zaw Zaw
  • 161
  • 1
  • 4
  • 1
    I did this with `android-11.0.0_r3` and still ended up with more than 60GB data (at which point my disk was full, so I don't even know how much it wanted). I wouldn't be surprised if you need a dedicated 2TB drive to build Android by 2025. – Forivin Oct 21 '20 at 11:04
  • 1
    `-f` is obsolete. – enigmaticPhysicist Jul 18 '21 at 15:26
8

repo init --depth 1

This is another option that might improve sync speed, as it should only download the latest version of the repos.

See also: https://superuser.com/questions/603547/how-can-i-limit-the-size-of-the-android-source-i-need-to-download-with-repo-syn

Here are my full test commands: How to compile the Android AOSP kernel and test it with the Android Emulator?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
7
repo sync -c --no-tags --no-clone-bundle -j2

Shortens my sync times greatly.

Merc
  • 393
  • 5
  • 10
  • 1
    Generally, answers are much more helpful if they include an explanation of what the command is intended to do, and why that solves the problem without introducing others. Can you expand on what the `-j2` switch does and how it helps? – Tom Aranda Dec 08 '17 at 21:59
  • 1
    `-j` is switch known from `make`, which sets number of jobs to be used (parallelism). `-j2` sets number of jobs to 2 (i.e. use 2 cores). On Linux you usually use `-j\`nproc\`` or `-j$(getconf _NPROCESSORS_ONLN)` to automatically detect number of cores. – pevik Dec 19 '17 at 20:58
  • This is not the case using `nproc`. The `-j` here set the number of threads for parallel network download, which is not CPU bound. `-j 4` is sufficient for most case. – ttimasdf Mar 19 '20 at 05:54