当前位置:   article > 正文

Android Studio导入Android源码_android.ipr

android.ipr
1.生成Android.ipr

进入项目根目录,执行

source build/envsetup.sh
lunch 项目版本号
make idegen -j16
  • 1
  • 2
  • 3

编译完成后有idegen.jar生成

执行

development/tools/idegen/idegen.sh
  • 1

会生成

android.ipr 和android.iml文件

若出现Couldn’t find idegen.jar. Please run make first.则需要执行

source build/envsetup.sh
mmm development/tools/idegen/
  • 1
  • 2

然后再执行

development/tools/idegen/idegen.sh
  • 1
2.导入Android.ipr

导入整个源码不仅浪费资源而且也会比较耗时,这时候需要给需要的目录导入到工程,打开android.iml文件,给不需要导入工程的目录添加进去(这个根据自己的需要),将以下内容复制到标签内

<excludeFolder url="file://$MODULE_DIR$/.repo" />
<excludeFolder url="file://$MODULE_DIR$/abi" />
<excludeFolder url="file://$MODULE_DIR$/art" />
<excludeFolder url="file://$MODULE_DIR$/bionic" />
<excludeFolder url="file://$MODULE_DIR$/bootable" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<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$/docs" />
<excludeFolder url="file://$MODULE_DIR$/libcore" />
<excludeFolder url="file://$MODULE_DIR$/libnativehelper" />
<excludeFolder url="file://$MODULE_DIR$/ndk" />
<excludeFolder url="file://$MODULE_DIR$/out" />
<excludeFolder url="file://$MODULE_DIR$/pdk" />
<excludeFolder url="file://$MODULE_DIR$/prebuilt" />
<excludeFolder url="file://$MODULE_DIR$/prebuilts" />
<excludeFolder url="file://$MODULE_DIR$/sdk" />
<excludeFolder url="file://$MODULE_DIR$/tools" />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

打开Android Studio,File->open,选择需要导入工程根目录下的android.ipr文件

image-20221130115441016

3.关联项目源码

因为AS默认会关联SDK里面的源码,为方便查看项目的源码,需要把SDK源码关联解除,这样我们点击查看某个class时就会打开项目源码的java文件,而不是SDK的class文件

  • File->Projects Structure->SDKs,新建一个取名JasonJDK,清空Classpath、Sourcepath、Annotations、Documentation Paths,也就是说新建一个空的JDK路径

    1

  • 选择Android API 32 Platform,如果没有的话去Android SDK里面随便下载一个版本即可,然后在Java SDK栏选择干刚刚新建的JasonJDK,清空Classpath,Sourcepath,Annotations,Documentation Paths

    3

    2

  • 点击Project,SDK栏选择Android API 32 Platform

    4

  • 点击Modules,点击android,在Dependencies栏删除除和Android API 32 Platform以外的所有jar

    5
    最后点击Apply->OK即可

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/319176?site
推荐阅读
相关标签
  

闽ICP备14008679号