Build "Sources for Android 28" so you can comfortably browse the Android API source in Android Studio.
- 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-9.0.0_r3 frameworks/base
git clone --depth 1 https://android.googlesource.com/platform/libcore -b android-9.0.0_r3
git clone --depth 1 https://android.googlesource.com/platform/development -b android-9.0.0_r3
# Create a basic source.properties file
echo -e "Pkg.UserSrc=false\nPkg.Revision=1\nAndroidVersion.ApiLevel=28" > source.properties
# Modify the script to create a sources ZIP to use "android-28" as top-level directory
cat development/build/tools/mk_sources_zip.py | sed -e 's/TOP_FOLDER = .*/TOP_FOLDER = "android-28"/' > my_mk_sources_zip.py
# Run the script to create android-28-sources.zip
python my_mk_sources_zip.py -z source.properties android-28-sources.zip .
- Extract into Android SDK source directory
unzip android-28-sources.zip -d ${ANDROID_HOME}/sources
- Restart Android Studio and SDK sources should show up.
@MIkeeJY
Replace
android-9.0.0_r3
branches withandroid10-release
branches.I used
Pkg.Revision=0
so SDK manager can update to official revision 1 when it comes out.Replace
android-28
in the last two commands withandroid-29
.I dropped the
-z
option because I run in Windows and there's no "zip
system exec". You'll need Python 2.7 to run the script.The rest is the same.