Tips of “repo sync” of Android

When we download Android source code, we use “repo sync” command. It takes long time. I show you the tips about “repo sync” to save time.
(Japanese version)

Reducing amount of download size by copying the existing repository

If you have already downloaded old source code (for example, android-2.2_r1.1), you can reduce amount of newly download size to use old repository. so you download only the difference.

$ mkdir android-2.3
$ cd android-2.3/
$ repo init -u git:// -b android-2.3.4_r1
$ cp -R ../android-2.2_r1.1/.repo/projects .repo/
$ repo sync

If you can overwrite the existing working directory,

$ mv android-2.2_r1.1 android-2.3
$ cd android-2.3
$ repo init -b android-2.3.4_r1
$ repo sync

I got this knowledge from Google group of Android Building(how do I switch branches by repo).

Option to run repo sync parallely

“make” command has ‘-j’ option to run multi jobs parallely. “repo sync” has similar option, too.
Let’s examine command line help.

$ repo sync -h
Usage: repo sync [...]

  -h, --help            show this help message and exit
  -f, --force-broken    continue sync even if a project fails to sync
  -l, --local-only      only update working tree, don't fetch
  -n, --network-only    fetch only, don't update working tree
  -d, --detach          detach projects back to manifest revision
  -q, --quiet           be more quiet
  -j JOBS, --jobs=JOBS  number of projects to fetch simultaneously
  -s, --smart-sync      smart sync using manifest from a known good build

  repo Version options:
    --no-repo-verify    do not verify repo source code

If you want to run 4 fetching jobs pararellely,

$ repo sync -j4

This can reduce the download time. However, be sure not to occupy the bandwidth of the network.

Related pages

Quick hack to run Android 2.3(Gingerbread) on KZM-A9-Dual board


About tetsu_koba

This entry was posted in Android. Bookmark the permalink.

7 Responses to Tips of “repo sync” of Android

  1. Pingback: Quick hack to run Android 2.3(Gingerbread) on KZM-A9-Dual board « Koba's blog

  2. Pingback: Android Source Tree building environment «

  3. frednyourface says:

    Thanks for the tip on copying existing files.
    I’ve been looking for a way to avoid the hours of download time when repo sync crashes on the 1GB android/prebuilt project and has to redownload hundreds of MB from the same project, again and again.
    Worked great!
    Appreciate you posting. I’ve looked for a solution for this many times, and this is the first thing I’ve found which helps.

  4. Lucian says:

    This is great! save me lots of time

  5. Chanchal says:

    you can use
    repo sync -c

  6. Sachin says:

    Refer following for adding a reference to existing android repo to sync quickly:

  7. Nice post!! To speed up repo sync use these tips

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s