Use repo on Windows to download android source

Android had developed repo tool to download huge android source code, primarily keeping in mind of development on Ubuntu / Linux and MacOS, but there are lot of people who just has access to Windows, so this post is to help those people with Windows, who can use below steps to download / repo sync android source code on Windows.

Note: On Windows, you can just download / repo sync the source code but you will not be able to compile the source code. Also, Windows has limitations with hyperlinks as used by repo and hyperlink creation is only supported for Admin permissions, hence if you don’t have admin permissions, its going to be difficult to repo sync code on Windows.

Dependencies

Repo is dependent on Python or rather “repo” tool itself is a python script, hence we need to install python as mentioned in our another post. “How to install Python on Windows”

Since repo uses git in backend and we need some terminal to start the repo, we will use the known terminal for git i.e. git-bash . You need to install it as mentioned in post “How to install git / git-bash on Windows”

Now you are mostly set to use download the source code, follow the below mentioned steps,

Start git-bash with “Right Click” and “Run as administrator”

As mentioned in the beginning, Windows doesn’t support hyperlink creation for non-admin users hence if you dont have admin permissions to start git bash, there are options as mentioned in https://github.com/git-for-windows/git/wiki/Symbolic-Links using which you can still be able to enable hyperlink creation with git-bash for non-admin user, but this also will need atleast once help from someone who has admin permissions to enable developer mode or other options as mentioned in link.

On the started terminal, create a directory and type below commands,

$ export MSYS="winsymlinks:nativestrict" 
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/repo 
$ chmod 777 ~/repo 

In this example, we will demo how you can download Android opensource code aosp, with branch “android-8.1.0_r7” , you can change it to your server url and branch as necessary.

$ mkdir aosp_src 
$ cd aosp_src 
$ ~/repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r75 
$ repo sync 

repo sync command may take hours depending on your network speed but Thats it wrt to commands, and you will be able to download complete android source on Windows.

Note: If you don’t start git bash as administrator, you will get following error during repo init,

$ ~/repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r75
Downloading manifest from https://android.googlesource.com/platform/manifest
error: in `init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r75`: Unable to create symbolic link. Please re-run the command as Administrator, or see https://github.com/git-for-windows/git/wiki/Symbolic-Links for other options.
Downloading Repo source from https://gerrit.googlesource.com/git-repo 

I.e. you will see an error as “Unable to create symbolic link. Please re-run the command as Administrator, or see https://github.com/git-for-windows/git/wiki/Symbolic-Links for other options.” which is again related to hyperlinks as mentioned earlier.

References –

Follow Lynxbee

Leave a Reply / Ask Question