1、准备好一份已经编译过的android源码
2、在linux下生成android.ipr等
执行下面的命令即可生成android.ipr等文件:
cd ~/aosp //具体的源码根目录
source build/envsetup.sh //用于初始化环境变量
mmm development/tools/idegen/ //生成文件out/host/linux-x86/framework/idegen.jar
./development/tools/idegen/idegen.sh//源码根目录生成文件android.ipr(工程相关设置), android.iml(模块相关配置)
3、windows下使用android_studio直接打开android源码目录
为了提高打开速度
接下来,使用文本编辑器打开"android.iml"文件,并执行以下修改
1、搜索关键字"orderEntry",我一般会将所有带有这个关键字的标签项全部删除,仅保留以下两行,大概如下
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
2、搜索关键字"out",将sourceFolder标签中带有out目录的全部删除。
3、搜索”excludeFolder“关键字,对这里进行一些修改,将我们不需要看的代码Exclude掉。通过这个步骤,能极大地提升第一次加载项目的速度。
对于exclude的部分,我们可以在项目加载完以后再进行调整就行了。
<excludeFolder url="file://$MODULE_DIR$/.repo" />
<excludeFolder url="file://$MODULE_DIR$/ImeCustom" />
<excludeFolder url="file://$MODULE_DIR$/art" />
<excludeFolder url="file://$MODULE_DIR$/audio_param_p61" />
<excludeFolder url="file://$MODULE_DIR$/bionic" />
<excludeFolder url="file://$MODULE_DIR$/bootable" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/ccu_tool" />
<excludeFolder url="file://$MODULE_DIR$/compatibility" />
<excludeFolder url="file://$MODULE_DIR$/cts" />
<excludeFolder url="file://$MODULE_DIR$/dalvik" />
<excludeFolder url="file://$MODULE_DIR$/developers" />
<excludeFolder url="file://$MODULE_DIR$/development" />
<excludeFolder url="file://$MODULE_DIR$/device" />
<excludeFolder url="file://$MODULE_DIR$/external" />
<excludeFolder url="file://$MODULE_DIR$/external/bluetooth" />
<excludeFolder url="file://$MODULE_DIR$/external/chromium" />
<excludeFolder url="file://$MODULE_DIR$/external/emma" />
<excludeFolder url="file://$MODULE_DIR$/external/icu4c" />
<excludeFolder url="file://$MODULE_DIR$/external/jdiff" />
<excludeFolder url="file://$MODULE_DIR$/external/webkit" />
<excludeFolder url="file://$MODULE_DIR$/frameworks/base/docs" />
<excludeFolder url="file://$MODULE_DIR$/hardware" />
<excludeFolder url="file://$MODULE_DIR$/kernel" />
<excludeFolder url="file://$MODULE_DIR$/kernel-3.18" />
<excludeFolder url="file://$MODULE_DIR$/kernel-4.4" />
<excludeFolder url="file://$MODULE_DIR$/kernel-4.9" />
<excludeFolder url="file://$MODULE_DIR$/libcore" />
<excludeFolder url="file://$MODULE_DIR$/libnativehelper" />
<excludeFolder url="file://$MODULE_DIR$/out" />
<excludeFolder url="file://$MODULE_DIR$/out/eclipse" />
<excludeFolder url="file://$MODULE_DIR$/out/host" />
<excludeFolder url="file://$MODULE_DIR$/out/target/common/docs" />
<excludeFolder url="file://$MODULE_DIR$/out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates" />
<excludeFolder url="file://$MODULE_DIR$/out/target/product" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/pdk" />
<excludeFolder url="file://$MODULE_DIR$/platform_testing" />
<excludeFolder url="file://$MODULE_DIR$/prebuilt" />
<excludeFolder url="file://$MODULE_DIR$/prebuilts" />
<excludeFolder url="file://$MODULE_DIR$/sdk" />
<excludeFolder url="file://$MODULE_DIR$/system" />
<excludeFolder url="file://$MODULE_DIR$/test" />
<excludeFolder url="file://$MODULE_DIR$/toolchain" />
<excludeFolder url="file://$MODULE_DIR$/tools" />
<excludeFolder url="file://$MODULE_DIR$/trusty" />
<excludeFolder url="file://$MODULE_DIR$/vendor" />
4、还可以对Android Studio\bin\studio64.exe.vmoptions进行修改,将
-Xms256m
-Xmx1280m
修改为
-Xms784m
-Xmx2560m