下载清华源的AOSP代码
1.安装Repo:
mkdir ~/bin
PATH=~/bin:$PATH
cd ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod a+x repo
2.修改REPO_URL
修改~/.bashrc文件,在开头加上:
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
3.配置邮箱和用户名
git config --global user.name "Your Name"
git config --global user.email "you@example.com" #这里要Gmail账号
4.指定需要下载的分支号
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r58
5.开始下载
repo sync [-j8]
导入AS
切换到AOSP源码目录,输入如下命令:
source build/envsetup.sh
make idegen
development/tools/idegen/idegen.sh
这样会在源码目录下生成android.ipr、android.iml2个文件
接下来调整AS的内存配置,修改ANDROID_STUDIO_HOME/bin/studio64.vmoptions
-Xms1280m
-Xmx1280m
然后打开AS,选择Open an exsiting Android Studio project。
导入完成后,需要配置Source目录,否则 ,点击一些类会跳转到Class文件。
在Product Settings->Modules,删除所有Jar包依赖,
接着点击+号,添加当前的源码文件作为依赖目录。