Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save quangson91/fe92d3e4c738e679b38f54afee9435ac to your computer and use it in GitHub Desktop.
Save quangson91/fe92d3e4c738e679b38f54afee9435ac 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