Search code examples
android-sourcerepo

Using Google's Repo Tool


Simple Question: How do I download android operating system source code version 8.0.0 using the repo tool on linux mint?

Detailed:

I want to download android source code. Edit some of the code, then install it onto a device. I installed a linux operating system, and downloaded/initialized repo. However, for the life of me I cannot understand how to use REPO.

I use the operating system tag: OPR4.170623.009. Which is android-8.0.0_r16 Oreo

That is the following command:

repo sync [OPR4.170623.009]

I get this result

... A new version of repo (2.12) is available.
... You should upgrade soon:
    cp /home/k/.repo/repo/repo /home/k/bin/repo

error: project [OPR4.170623.009] not found

I even tried

repo sync [<OPR4.170623.009>]

I got

bash: OPR4.170623.009: No such file or directory

It is very weird, because the 'Downloading the Source' page doesn't really one on how to actually download the source. (https://source.android.com/setup/build/downloading#initializing-a-repo-client). It makes is seem like I should be using sync, and the 'source code tags'. However it doesn't say how to put those two together:

Here:

repo sync [project0 project1 ... projectn]
repo sync [/path/to/project0 ... /path/to/projectn]

It shows some example, but that doesn't look anything like their tags?


Solution

  • The version you want to download has to be specified for repo init, not for repo sync. Also, the version is specified using the tag, not the build ID (the second column in this list).

    So the steps you have to take would be as follows:

    • Initialize the repo with the build tag you want (for example android-8.0.0_r16):

      repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r16
      
    • Synchronize the repo:

      repo sync --jobs=32 --current-branch --no-tags --quiet
      

      The additional flags passed to repo sync are not required, but might be helpful: The flag --jobs=32 will attempt 32 downloads in parallel (adjust to your network bandwidth). The flag --current-branch will download only the branch you have specified during repo init. The flag --no-tags will disable downloading of tag data. With the flag --quiet only the overall download progress will be shown.

    Some general note: You indicated that you want to flash the image to a device. Note that your device will likely require device specific drivers to be included in the image. These drivers are generally not part of AOSP. Also, your device may have a locked boot loader that does not allow flashing custom images. I cannot give more details since I don't know the device you are targeting.