如何使用Android Studio开发/调试Android源码

如何使用Android Studio开发/调试Android源码

https://www.linuxidc.com/Linux/2015-04/116459.htm

source build/envsetup.sh

lunch

kheard

出现Exception in thread "main" java.lang.UnsupportedClassVersionError: Main : Unsupported major.minor version 52.0

查看java版本是否正确

mmm development/tools/idegen/

development/tools/idegen/idegen.sh

AS在导入代码时比较慢,建议先修改android.iml,将自己用不到的代码exclude出去.可以仿照过滤.repo文件夹的语法,如:

<excludeFolder url="file://$MODULE_DIR$/.repo" />
<excludeFolder url="file://$MODULE_DIR$/abi" />
<excludeFolder url="file://$MODULE_DIR$/art" />

<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="android" name="Android">
      <configuration />
    </facet>
  </component>
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/frameworks" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/packages" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/gen" type="java-test-resource" />
      <sourceFolder url="file://$MODULE_DIR$/system" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/vendor/sprd/platform" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/art" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/frameworks/base" isTestSource="false" />
      <excludeFolder url="file://$MODULE_DIR$/.repo" />
      <excludeFolder url="file://$MODULE_DIR$/art" />
      <excludeFolder url="file://$MODULE_DIR$/bionic" />
      <excludeFolder url="file://$MODULE_DIR$/bootable" />
      <excludeFolder url="file://$MODULE_DIR$/bsp" />
      <excludeFolder url="file://$MODULE_DIR$/build" />
      <excludeFolder url="file://$MODULE_DIR$/build/blueprint" />
      <excludeFolder url="file://$MODULE_DIR$/build/kati" />
      <excludeFolder url="file://$MODULE_DIR$/build/soong" />
      <excludeFolder url="file://$MODULE_DIR$/captures" />
      <excludeFolder url="file://$MODULE_DIR$/chipram" />
      <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$/device/common" />
      <excludeFolder url="file://$MODULE_DIR$/device/generic" />
      <excludeFolder url="file://$MODULE_DIR$/device/google" />
      <excludeFolder url="file://$MODULE_DIR$/device/linaro" />
      <excludeFolder url="file://$MODULE_DIR$/device/sample" />
      <excludeFolder url="file://$MODULE_DIR$/device/sprd/pike2/sp7731e_1h20" />
      <excludeFolder url="file://$MODULE_DIR$/device/sprd/qogirn6pro" />
      <excludeFolder url="file://$MODULE_DIR$/device/sprd/sharkl3" />
      <excludeFolder url="file://$MODULE_DIR$/device/sprd/sharkl5Pro" />
      <excludeFolder url="file://$MODULE_DIR$/device/sprd/sharkle" />
      <excludeFolder url="file://$MODULE_DIR$/device/ti" />
      <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/av" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/base/docs" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/compile" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/data-binding" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/ex" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/hardware" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/layoutlib" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/minikin" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/ml" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/multidex" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/native" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/opt" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/rs" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/support" />
      <excludeFolder url="file://$MODULE_DIR$/frameworks/wilhelm" />
      <excludeFolder url="file://$MODULE_DIR$/hardware" />
      <excludeFolder url="file://$MODULE_DIR$/kernel" />
      <excludeFolder url="file://$MODULE_DIR$/kernel4.14" />
      <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$/pac" />
      <excludeFolder url="file://$MODULE_DIR$/packages/apps/Camera2" />
      <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$/priv-app" />
      <excludeFolder url="file://$MODULE_DIR$/prop-rietories" />
      <excludeFolder url="file://$MODULE_DIR$/res" />
      <excludeFolder url="file://$MODULE_DIR$/sdk" />
      <excludeFolder url="file://$MODULE_DIR$/sign_modem" />
      <excludeFolder url="file://$MODULE_DIR$/test" />
      <excludeFolder url="file://$MODULE_DIR$/toolchain" />
      <excludeFolder url="file://$MODULE_DIR$/tools" />
      <excludeFolder url="file://$MODULE_DIR$/u-boot15" />
      <excludeFolder url="file://$MODULE_DIR$/u-boot64" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/partner_gms/apps" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/partner_gms/apps_go" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/partner_gms/doc" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/build" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/carriers" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/external" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/feature_configs" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/interfaces" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/plugins" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/proprietories-source" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/release" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/sprd-webview" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/sprd/tools" />
      <excludeFolder url="file://$MODULE_DIR$/vendor/widevine" />
    </content>
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
  </component>
</module>

打开 Android Studio,选择 Open an existing Android Studio project,找到源码目录,点击 Android.ipr,Open

在最后etc/sysctl.conf添加

fs.inotify.max_user_watches = 5242881

运行 sudo sysctl -p

文件跳转右键点击工程 open moudle settings

将framework和external等文件夹mark as Sources即可解决

 Android studio 不停 scanning files to index

1 invalidate and restart 不起作用

2 Open module setting --> Modules --> 找到gen文件夹  --> 右键选择Resources,

导入了源码以后,工程非常大 要开其他工程一定不要用 file-open Recent(很容易卡死)

要使用 file - open 去选择工程打开
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值