Skip to content

Instantly share code, notes, and snippets.

@technoir42
Last active August 7, 2018 15:08
Show Gist options
  • Save technoir42/f3b22ce0d104da230036c9620ce9e2cf to your computer and use it in GitHub Desktop.
Save technoir42/f3b22ce0d104da230036c9620ce9e2cf to your computer and use it in GitHub Desktop.
api=28
branch=android-9.0.0_r3
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 $branch frameworks/base
git clone --depth 1 https://android.googlesource.com/platform/libcore -b $branch
git clone --depth 1 https://android.googlesource.com/platform/development -b $branch
# Create a basic source.properties file
echo -e "Pkg.UserSrc=false\nPkg.Revision=1\nAndroidVersion.ApiLevel=$api" > source.properties
# Modify the script to create a sources ZIP to use "android-$api" as top-level directory
cat development/build/tools/mk_sources_zip.py | sed -e "s/TOP_FOLDER = .*/TOP_FOLDER = \"android-$api\"/" > my_mk_sources_zip.py
# Run the script to create android-$api-sources.zip
python my_mk_sources_zip.py -z source.properties "android-$api-sources.zip" .
# Extract into Android SDK source directory
unzip "android-$api-sources.zip" -d ${ANDROID_HOME}/sources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment