Call for Help: making free software builds of the Android SDK

Sorry, I’m the bottleneck on too many things. Thanks for keeping on nagging. I was waiting for the details like the name and proper packaging and setup before setting up the official repo.

About the naming, I think sdkmanager renames the directory based on data in The official packages also have a base dir of android-9 for build-tools-28.0.3.

Have you tried doing a diffoscope run on your builds vs the original builds? That could be quite useful to see what the diffs are.

About the name, I think I like /android-free/ the best. It is close to Google’s name, which is just /android/, with the essential difference that these builds are actually free, while theirs are not.

1 Like

Let’s go with android-free then. It would be good to start the repo so we can experiment with it.

1 Like

works for me, I’ll set it up this week

Ok, it is setup:

I think we should follow the conventions of the Google repositories as much as possible. For example repository.xml should have the version number in it for the format that we are using, e.g. repository-12.xml And the dir structure should be the same. Otherwise, I think we’ll see weird issues, since a lot of the Android SDK was not designed to be decentralized and is quite brittle.

Here are some examples:

That also means naming the ZIP files the same, e.g. or

1 Like

FYI, that rsync command is strict, as enforced on the server/remote side. That means if you run it with different options, it will fail. You can add these though for debugging: --verbose --progress The local path can be freely changed, but the remote path cannot.

Thanks a lot - I didn’t get notified so I only noticed today while about to complain :wink:
I’m merging a fresh rebuild (that includes the aforementioned build-tools-28.0.3 at last).
(give it some time to upload)

There seem to be another xml location for ‘samples’ and ‘sources’ packages, which I didn’t find.
Also I’m not sure if we should symlink e.g. repository.xml to repository-10.xml.

Is there a way to pass this repository URL to sdkmanager without recompiling it?

Added a new system image compiled during the night! seems important to locate the sys-img additional repository. Lots a naming conventions and lack of provider-oriented documentation makes it difficult to figure things out.

There’s a thing called “user defined sites” but I don’t think this’d work as we want to have priority over the default google repositories.

I don’t use this kind of tools so any help is appreciated :slight_smile:

It is possible to add new repositories both via the GUI and via a config file. In Android Studio, go to Tools --> SDK Manager --> SDK Update Sites. For a config file, this should work for these repos if put in ~/.android/repositories.cfg:

disp00=Android Free SDK
disp01=Android Free System Images

No need for symlinks or aliases for the XML files, there isn’t a standard path that sdkmanager users for discovery. It is based on providing full URLs.

@Beuc Could you include the existing F-Droid system image in this setup? It is currently available here:

It would be amazing to have F-Droid flavors of emulators in this new repo. @cdesai is your build setup for that F-Droid system image somewhere accessible?

Also, FYI, I forgot to change the access logging on the webserver, so the default was enabled up until now. I’m switching it to this proven config which strips out user-identifying info:

Yeah that what I called “user-defined sites” - but that doesn’t do the trick, since we want to have priority. E.g. if the user’s build environment requests “platform-28”, we want sdkmanager to download our build, rather than attempt to download a newer revision with a proprietary license from google.

Also the URL scheme doesn’t seem to work:

$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 tools/bin/sdkmanager --update
Warning: Failed to fetch URL, reason: File not found
Warning: Failed to fetch URL, reason: File not found

About the F-Droid system images: how are they built - i.e. what is the license?

I guess I haven’t tried doing the repository replacement before, it seems to have different rules than the system images. I guess we have to dig into the sdkmanager source code to figure what the requirements are for setting up a repository to replace Google’s. I see an error in the XML:

Warning: Errors during XML parse:                                                                                
Warning: cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.                                                                                
Warning: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 70; cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.                                                                                
Warning: javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 70; cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.]                                                                                
Warning: Additionally, the fallback loader failed to parse the XML.

I think the Google repositories are hard coded in. There used to be a way to be able to disable them in repositories.cfg, something like adding an entry for those URLs in the same style as I outlined above, but then adding something like enabled02=false.

@cdesai build the F-Droid system images, I think they are probably Apache-2.0 licensed.

I had tested with a modified and an empty “repository-10.xml” and there’s still the same XML error, I figure it’s related to the 404 error above.

By the way the current XMLs are manual copy/pastes of bits produced by the rebuilds, with modified filenames. This is for initial testing. Next we’ll want to automate some of this - if there are existing tools, that would help.

I put together a quick script to scrape all the XML from the Google repository:

#!/bin/sh -ex

wget="wget --continue --quiet"


for name in addon repository sys-img; do
    $wget $baseurl/${name}.xml &
    for i in x86 x86_64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
        $wget $baseurl/${name}-${i}.xml &

It seems that your repository-10.xml is totally different from the one that I downloaded. How about starting with the one downloaded from Google, then use symlinks to match the filenames, and change the sha256 sums. Then we can see what we need to change, I think it won’t be much.

As for auto-generating the XML, that should be relatively easy to do once we figure out what matters in that file.

This looks like the script they use to generate the XML:

And these seem to be the .xsd files used by that script:

I built the F-Droid system images using the AOSP source code without any modifications.

To include the privileged extension it simply needs to be placed in the AOSP source tree, and then built via PRODUCT_PACKAGES += F-DroidPrivilegedExtension

You should definitely generate the XMLs via the script, that’s what I did for the system images. contains the scripts and files used.

Thanks for the pointers.
@cdesai There doesn’t seem to be any occurrence of PRODUCT in your scripts - did you use some equivalent?

(also the XML bits generated by the rebuilds already use that script:)

/bin/bash -c "development/build/tools/	            out/host/linux-x86/sdk/sdk_x86_64/repository.xml prebuilts/devtools/repository/sdk-repository-10.xsd  build-tools linux out/host/linux-x86/sdk/sdk_x86_64// platform-tools linux out/host/linux-x86/sdk/sdk_x86_64// docs linux out/host/linux-x86/sdk/sdk_x86_64// platforms linux out/host/linux-x86/sdk/sdk_x86_64// samples linux out/host/linux-x86/sdk/sdk_x86_64// sources linux out/host/linux-x86/sdk/sdk_x86_64//"

Starting from a file from Google with a huge proprietary license on top doesn’t sound good.
Before rebuilding the XML this or that way, we need to be able to actually test it though :slight_smile:
I had made a quick skim in sdklibs, it’s a bit hard to figure things out, some of it is depracated, and some of the sdkmanager logic is in another subproject afaics.

@Beuc For the privext, I did this hack temporarily.

Unsure as to what proprietary license you’re referring too, all of the code linked above / used by me is Apache 2.

I was answering to @hans wrt using google’s repository.xml as a starting point, sorry I wasn’t clear.

Congratulations and thank you to the people who worked for those builds to happen. If there are some guides/posts on how to use them that 'd be really helpful (if anyone can post them here or point to where they are).

Thanks for your supporting message!
Right now the easiest is downloading and extracting a bundle from but we’d like to setup the new repository so people could use grab individual components (and pick versions) directly from sdkmanager.
This requires overriding google’s repos in that tool, and setup the new repo accordingly. All help is welcome :slight_smile: