aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用

这篇具有很好参考价值的文章主要介绍了aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

hi,粉丝朋友:

近期又粉丝朋友聊到了如果做aosp系统应用开发,有什么工具或者方式来导入代码可以正常跳转和代码提示等?
更多内容: https://blog.csdn.net/learnframework/article/details/130016893

Android Studio导入系统源码

针对这个问题其实我课程里面的[入门课就有有讲解android studio导入整套系统源码]的详细说明,这里就再次补充一下android studio导入android系统源码
1、生成对应的android.ipr和android.iml文件

 make idegen -j4
 “development/tools/idegen/idegen.sh” (报错find: ‘out/target/product/generic_x86_64/root/d’: Permission denied没有关系不影响ipr和iml文件生成)
 sudo chmod 777 android.iml android.ipr
 2、有了ipr和iml,删减一部分android.iml的内容,主要原因源码太多,要排除部分没用项目,还有就是依赖部分只留下自己moudle就可以
 把android.iml中的excludeFolder标签都删除用以下标签
<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$/compatibility" />
      <excludeFolder url="file://$MODULE_DIR$/cts" />
      <excludeFolder url="file://$MODULE_DIR$/dalvik" />
      <excludeFolder url="file://$MODULE_DIR$/developers" />
      <excludeFolder url="file://$MODULE_DIR$/developers/samples" />
      <excludeFolder url="file://$MODULE_DIR$/development" />
      <excludeFolder url="file://$MODULE_DIR$/device" />
      <excludeFolder url="file://$MODULE_DIR$/device/google" />
      <excludeFolder url="file://$MODULE_DIR$/device/sample" />
      <excludeFolder url="file://$MODULE_DIR$/docs" />
      <excludeFolder url="file://$MODULE_DIR$/external" />
      <excludeFolder url="file://$MODULE_DIR$/flashing-files" />
      <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$/libcore" />
      <excludeFolder url="file://$MODULE_DIR$/libnativehelper" />
      <excludeFolder url="file://$MODULE_DIR$/out" />
      <excludeFolder url="file://$MODULE_DIR$/out/soong/.intermediates" />
      <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$/shortcut-fe" />
      <excludeFolder url="file://$MODULE_DIR$/system" />
      <excludeFolder url="file://$MODULE_DIR$/test" />
      <excludeFolder url="file://$MODULE_DIR$/toolchain" />
      <excludeFolder url="file://$MODULE_DIR$/tools" />

把orderEntry标签都删除,只剩下如下两个即可以,这样跳转时候就不会跳其他jar

 <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="jdk" jdkName="Android API 33 Platform" jdkType="Android SDK" />

这样android studio就完全可以进行相关的跳转了,同时各个app其实也可以进行跳转,如下图的Settings:

aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用

这种其实也有一些androidx库依赖标红啥的,这个相对比较少影响不是太大,不过这个也可能是很多同学不喜欢的点,那么有啥更好办法解决么?当然有,那就是今天主题AIDEGen

AIDEGen导入各个模块代码

AIDEGen相关文档:
tools/asuite/aidegen/README.md

首先看它的相关官方readme,英文的,其实也比较好懂,这里就不做翻译了,我相信也完全可以看懂

AIDEGen

AIDEGen aims to automate the project setup process for developers to work on
Java or C/C++project in popular IDE environment. Developers no longer need to manually
configure an IntelliJ project, such as all the project dependencies. It’s a
command line tool that offers the following features:

  • Configure Android Studio or IntelliJ project files with the relevant module
    dependencies resolved.

  • Launch IDE for a specified sub-project or build target, i.e. frameworks/base
    or Settings.

  • Launch IDE for specified folder(s) which contains build targets, i.e. cts.

  • Auto configure JDK and Android coding style for IntelliJ.

(上面其实就是说明了一下AIDEGen是干啥的,大概意思就是它是一个自动生成项目配置文件,针对不同的主流ide都是可以的,比如 Android Studio or IntelliJ project等,就不需要我们自己针对不同ide来搞对应项目)

1. Prerequisites:

  • IDE installation, choose one of prefer IDE, including Android Studio,
    IntelliJ IDEA, Eclipse, CLion and VS Code.

  • Setup Android development environment.

$ source build/envsetup.sh && lunch <TARGET>

(以上是预备条件,配置好aosp的env和lunch,而且要本身系统安装好了的对应的ide,比如Android Studio,IntelliJ IDEA, Eclipse, CLion and VS Code)

2. Basic Usage:

Example 1: Launch IDE with module name

Example to generate and launch IntelliJ project for framework and Settings:
可以直接使用module name来进行对应的启动

$ aidegen Settings framework

Example 2: Launch IDE with module path

Example to generate and launch IntelliJ project for framework and Settings:
可以直接使用module path来进行对应的启动

$ aidegen packages/apps/Settings frameworks/base

Example 3: Launch IDE with build skipped

Example to generate and launch IntelliJ project for framework and Settings and
skip build time:
这里可以用-s来跳过编译,一般使用这种如果已经编译了的话

$ aidegen Settings framework -s

Example 4: Launch IDE with native module

Example to generate and launch CLion project:

$ aidegen <module> -i c

The native projects will be launched in CLion and you have to select,
Tools > CMake > Change Project Root
Change project root to the source directory: the relative path which is the directory shown in CLion’s project view. For example, if frameworks/base/media is your project, please change project root directly to frameworks/base/media.

3. Optional arguments:

Developers can also use the following optional arguments with AIDEGen commands.

Option Long option Description
-d --depth The depth of module referenced by source.
-i --ide Launch IDE type, j=IntelliJ s=Android Studio e=Eclipse c=CLion v=VS Code
-p --ide-path Specify user’s IDE installed path.
-n --no_launch Do not launch IDE.
-r --config-reset Reset all AIDEGen’s saved configurations.
-s --skip-build Skip building jars or modules.
-v --verbose Displays DEBUG level logging.
-a --android-tree Generate whole Android source tree project file for IDE.
-e --exclude-paths Exclude the directories in IDE.
-l --language Launch IDE with a specific language,j=java c=C/C++ r=Rust
-h --help Shows help message and exits.

4. Troubleshooting tips:

If you get an error like: “Dependent modules dictionary is empty.” or other errors, try a make
clean.

5. FAQ:

Q1. If I already have an IDE project file, and I run command AIDEGen to generate
the same project file again, what’ll happen?

A1: The former IDEA project file will be overwritten by the newly generated one
from the aidegen command.

Q2: When do I need to re-run AIDEGen?

A2: Re-run AIDEGen after repo sync.

6. Hint:

  1. In IntelliJ, uses [File] > [Invalidate Caches / Restart…] to force
    project panel updated when your IDE didn’t sync.

  2. If you run aidegen on a remote desktop, make sure there is no IntelliJ
    running in a different desktop session.

6. Feedback:

If you have any questions or feedback, contact aidegen_tnn@google.com.

If you have any bugs or feature requests email them to buganizer-system+429701@google.com.

实战体验Settings

命令:

aidegen packages/apps/Settings -i s -s

aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用

针对androidx等也不会报错
aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用

相对系统app来说确实体验还是很不错,比源码整体导入那种相对更好一些,也非常简单,不需要为了Setting导入整套代码,跳转framework部分的代码也是正常的:
aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用文章来源地址https://www.toymoban.com/news/detail-413399.html

到了这里,关于aosp11/12/13 framework源码开发IDE工具之idegen/aidegen/AIDEGen详细使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Repo下载、编译AOSP源码:基于Ubuntu 21.04,android-12.1.0_r27

    最近准备更新专栏文章,AOSP源码自然也需要进行更新了,但这次不是为最新的android 13, 而是取android 12的最新tag version: android-12.1.0_r27,这应该是市面上的主流版本。 每次更新,自然也会遇到问题,所以就记录一下 另外,这次我们将直接配置本地服务器,而不是通过docker,让

    2023年04月26日
    浏览(35)
  • Android12 源码下载、编译、刷机、单编调试Framework

    深入学习Android系统框架开发前,首先要搭建Android工程的开发环境(建房子前先搞地基),详细的配置要求和操作步骤见官网说明 Establishing a build environment,本文也汇总了Android 12工程源码的下载、编译和刷机的实操过程。 在开始代码下载之前,先强调下源码编译对硬件/软件

    2024年02月03日
    浏览(47)
  • MIUI14+安卓13 Root教程 小米10 小米11 小米12 小米13 红米

    1. 确保手机已完成 BL 解锁。这里来申请解锁 2. 手机下载并且安装Magisk 下载地址 3. 去下载当前版本刷机包 小米 10 (umi) 国行版 线刷、卡刷包 ​ 网页上ctrl+f 搜索 miui14,直接找到最新版,目前版本是: ​ V14.0.2.0.TJBCNXM MIUI14 13.0 ​ miui_UMI_V14.0.2.0.TJBCNXM_6d38dfc521_13.0.zip | 下载 4.把

    2023年04月16日
    浏览(50)
  • 关于Android 11、12和13服务保活问题

    物联网环境,为了解决不同厂商、不同设备、不同网络情况下使用顺畅,同时也考虑到节约成本,缩小应用体积的好处,我们需要一个服务应用一直存在系统中,保活它以提供服务给其他客户端调用。 开机自启动,通过广播通信, 必要权限 开机自启动Service相关代码 注意

    2023年04月08日
    浏览(76)
  • 【每日刷题】动态规划-代码随想录动规-11、12、13

    问题背景 : 有若干个物品对应各自的体积和价值,有一个容量确定的背包,有选择的将物品装进背包里,求可放进背包的最大价值。 思路: 定义dp数组: dp[i][j]的含义:从下标为[0-i]的物品里任意取,放进容量为j的背包,价值总和最大是多少。 dp[i][j]递推公式: 不放物品

    2024年02月22日
    浏览(46)
  • 【Android Framework系列】第11章 LayoutInflater源码分析

    本章节我们主要目目的是了解 Activity 的 xml 布局解析、对 LayoutInfater 源码进行分析。 我们知道Android界面上的每一个控件都是一个个 View ,但是Android也提供了通过 xml 文件来进行布局控制,那么 xml 布局文件如何转成最终的 View 的呢?转换利器就是 LayoutInflater 。在分析 Layout

    2024年02月12日
    浏览(33)
  • 【Android12】Android Framework系列---Adb和PMS安装apk源码流程

    通过adb install命令可以将apk安装到Android系统(注意:特定类型的apk,比如persist类型是无法通过adb安装的) 下述命令中adb解析install命令,并调用Android PackageManagerService进行apk安装。 基于Android12,分析从adb install到 PakcageManagerService安装apk的流程。 adb install命令的源码实现 Andro

    2024年01月22日
    浏览(58)
  • C Primer Plus(第六版)11.13 编程练习 第12题

    /* 编写一个程序,读取输入,直至读到EOF,报告读入的单词数、大写字母数、小写字母数、标点 符号数和数字字符数。使用ctype.h头文件中的函数。 */ //测试字符串  //ajskm,dl kdAj,.lfj sjkdl  sdk12lfj !.,fkdj.,.lssd.1a //(ajskm),(dl) (kdAj),.(lfj) (sjkdl)  (sdk)12(lfj) !.,(fkdj).,.(lssd).1(a) #includestdi

    2024年02月02日
    浏览(35)
  • 如何在 iPhone 15/14/13/12/11/XS/XR 上恢复误删除的短信?

    无论你的iPhone功能多么强大,数据丢失的情况仍然时有发生,所以当你发现一些重要的消息有一天丢失了。别担心,让自己冷静下来,然后按照本页的方法轻松从 iPhone 中检索已删除的短信。 在这里,您需要奇客数据恢复iPhone版 的帮助。该工具是一款针对 iPhone、iPad 或 iPod

    2024年04月09日
    浏览(96)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包