操作基于源码全编译成功。
编译源码方法请参考下载及编译Android源码
mmm development/tools/idegen/
sudo development/tools/idegen/idegen.sh
命令执行成功后,在项目的根目录会出现3个文件:
1.android.iml
2.android.ipr
3.android.iws
生成出来的android.iml和android.ipr都是可读不可写,在导入源码的时候会有错误。
这里提前修改文件的权限
sudo chmod 777 android.iml
sudo chmod 777 android.ipr
随后查看项目根目录下的 development/tools/idegen/README
Android is large, thus IDEA needs a lot of memory. Add "-Xms1g -Xmx5g" to
your VM options in "Help > Edit Custom VM" and increase the
file size limit in "Help -> Edit custom properties" by adding
"idea.max.intellisense.filesize=100000". Make sure to restart the IDE for
the new settings to take effect.
Google官方文档对配置文件的说明:
Android Studio 通过 Help 菜单提供对两个配置文件的访问:
studio.vmoptions
:自定义 Studio Java 虚拟机 (JVM) 的选项,如堆内存和缓存大小。请注意,对于 Linux 机器,此文件可能命名为studio64.vmoptions
,具体取决于您的 Android Studio 版本。idea.properties
:自定义 Android Studio 的属性,如插件文件夹路径或最大支持文件大小。
修改完成后,打开Android Studio ->open an existing Android Studio Project->选择项目根目录下的android.ipr文件进行导入
在导入的过程中我遇到了如下图的转换提示
点击convert,自动修改了android.iml。原有的android.iml被放到了项目根目录下的projectFileBackup文件夹中,不影响源码的导入。
成功导入源码之后,你会发现项目一直在Indexing,耗时非常久。
除了可以通过修改studio.vmoptions和idea.properties这两个配置文件加快速度;
我们还可以通过Excluded掉不常用的文件夹来加快Android Studio检索目录的过程。
File > Project Structure > 弹出的窗口左侧Project Settings > Modules > 窗口的中间android > 窗口的右侧Sources
在点击Sources之后弹出的列表中选择不需要的文件夹进行Excluded操作。