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