Skip to content

Instantly share code, notes, and snippets.

@cketti
Last active August 14, 2019 12:08
Show Gist options
  • Star 50 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save cketti/724c5cd15ff69517540fe0aba7f7dc56 to your computer and use it in GitHub Desktop.
Save cketti/724c5cd15ff69517540fe0aba7f7dc56 to your computer and use it in GitHub Desktop.
Build your own android-26 sources

If you are annoyed that "Sources for Android 26" are not yet available via SDK manager, this might be for you:

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base

# Fetch repositories that contain the sources we're interested in
git clone --depth 1 https://android.googlesource.com/platform/frameworks/base -b android-8.0.0_r4 frameworks/base
git clone --depth 1 https://android.googlesource.com/platform/libcore -b android-8.0.0_r4
git clone --depth 1 https://android.googlesource.com/platform/development -b android-8.0.0_r4

# Create a basic source.properties file
echo -e "Pkg.UserSrc=false\nPkg.Revision=1\nAndroidVersion.ApiLevel=26" > source.properties

# Modify the script to create a sources ZIP to use "android-26" as top-level directory
cat development/build/tools/mk_sources_zip.py | sed -e 's/TOP_FOLDER = .*/TOP_FOLDER = "android-26"/' > my_mk_sources_zip.py

# Run the script to create android-26-sources.zip
python my_mk_sources_zip.py -z source.properties android-26-sources.zip .
  1. Extract into Android SDK source directory
unzip android-26-sources.zip -d ${ANDROID_HOME}/sources
  1. Restart Android Studio and SDK sources should show up.
@cketti
Copy link
Author

cketti commented Sep 11, 2017

The ZIP file created in step 1: https://hugo.cketti.eu/android-26-sources.zip (28 MB)

@rharter
Copy link

rharter commented Sep 11, 2017

Oneliner:

curl -o /tmp/android-26-sources.zip https://hugo.cketti.eu/android-26-sources.zip && unzip /tmp/android-26-sources.zip -d ${ANDROID_HOME}/sources && rm /tmp/android-26-sources.zip

@alphamu
Copy link

alphamu commented Sep 12, 2017

#LoveIt. Can't believe I didn't think of this!

@J-Swift
Copy link

J-Swift commented Sep 15, 2017

Thanks for this. I converted to a more generalized version if anyone prefers that:

https://gist.github.com/J-Swift/539aaf82ffac21d5515274a24379667f

@SanityResort
Copy link

Awesome, that bugged me for the last two weeks. Thanks!!

@cketti
Copy link
Author

cketti commented Dec 18, 2017

@joshfriend
Copy link

@muhdamean
Copy link

Wow this is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment