1、準(zhǔn)備好一份已經(jīng)編譯過的android源碼
2沦零、在linux下生成android.ipr等
執(zhí)行下面的命令即可生成android.ipr等文件:
cd ~/aosp //具體的源碼根目錄
source build/envsetup.sh //用于初始化環(huán)境變量
mmm development/tools/idegen/ //生成文件out/host/linux-x86/framework/idegen.jar
./development/tools/idegen/idegen.sh//源碼根目錄生成文件android.ipr(工程相關(guān)設(shè)置), android.iml(模塊相關(guān)配置)
3、windows下使用android_studio直接打開android源碼目錄
為了提高打開速度
接下來葫哗,使用文本編輯器打開"android.iml"文件则酝,并執(zhí)行以下修改
1、搜索關(guān)鍵字"orderEntry"庄敛,我一般會將所有帶有這個關(guān)鍵字的標(biāo)簽項全部刪除俗壹,僅保留以下兩行,大概如下
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
2藻烤、搜索關(guān)鍵字"out",將sourceFolder標(biāo)簽中帶有out目錄的全部刪除绷雏。
3、搜索”excludeFolder“關(guān)鍵字怖亭,對這里進行一些修改涎显,將我們不需要看的代碼Exclude掉。通過這個步驟兴猩,能極大地提升第一次加載項目的速度期吓。
對于exclude的部分,我們可以在項目加載完以后再進行調(diào)整就行了倾芝。
<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