首页 > 其他分享 >Android配置Framework开发环境

Android配置Framework开发环境

时间:2024-06-01 19:00:59浏览次数:13  
标签:-- 配置 aidegen idea Framework Studio Android IDE

联系作者:私信 或者 个人主页

1. 解决的问题

Android开发中,有很大一部分是Framwrok定制开发,即需要阅读、修改frameworks仓库下的java代码,本文解决如何配置一个好用的framework跳转环境问题。

本文介绍的是使用aidegen + android studio配置。

首先简单介绍一下aidegen是什么,它是谷歌内置的一个脚本,用于生成各个IDE的工程,包括Android Studio、CLion、IntelliJ、Eclipse、VSCode,其中用于的较多的是Android Studio,用于生成Java工程,C++工程这个方案并不理想,如果需要配置C++开发环境,可以参考我的另一篇文章:Android配置C++开发环境

2. 实践步骤

下面以Android12为例说明

2.1. 生成Android Studio工程

$ aidegen --help
usage: aidegen [module_name1 module_name2... project_path1 project_path2...]

AIDEgen

This CLI generates project files for using in IntelliJ, such as:
    - iml
    - .idea/compiler.xml
    - .idea/misc.xml
    - .idea/modules.xml
    - .idea/vcs.xml
    - .idea/.name
    - .idea/copyright/Apache_2.xml
    - .idea/copyright/progiles_settings.xml

- Sample usage:
    - Change directory to AOSP root first.
    $ cd /user/home/aosp/
    - Generating project files under packages/apps/Settings folder.
    $ aidegen packages/apps/Settings
    or
    $ aidegen Settings
    or
    $ cd packages/apps/Settings;aidegen

positional arguments:
  targets               Android module name or path.e.g. Settings or packages/apps/Settings

optional arguments:
  -h, --help            show this help message and exit
  -d {0,1,2,3,4,5,6,7,8,9}, --depth {0,1,2,3,4,5,6,7,8,9}
                        The depth of module referenced by source.
  -v, --verbose         Display DEBUG level logging.
  -i IDE, --ide IDE     Launch IDE type, j: IntelliJ, s: Android Studio, e: Eclipse, c: CLion, v: VS Code. The default value
                        is 'u': undefined.
  -p IDE_INSTALLED_PATH, --ide-path IDE_INSTALLED_PATH
                        IDE installed path.
  -n, --no_launch       Do not launch IDE.
  -r, --config-reset    Reset all saved configurations, e.g., preferred IDE version.
  -s, --skip-build      Skip building jars or modules that create java files in build time, e.g. R/AIDL/Logtags.
  -a, --android-tree    Generate whole Android source tree project file for IDE.
  -e [EXCLUDE_PATHS [EXCLUDE_PATHS ...]], --exclude-paths [EXCLUDE_PATHS [EXCLUDE_PATHS ...]]
                        Exclude the directories in IDE.
  -V, --version         Print aidegen version string.
  -l LANGUAGE, --language LANGUAGE
                        Launch IDE with a specific language, j: Java, c: C/C++, r: Rust. The default value is 'u':
                        undefined.

INFO: To report the AIDEGen tool problem, please use this link: https://goto.google.com/aidegen-bug

常用命令如下(以下用于生成frameworks仓库的Android Studio工程):

$ aidegen -i s -n frameworks/

2.2. Android Studio配置

其实我们的最终目标是想在Windows下面使用Android Studio打开远程服务器的工程,因为大部分的开发模式还是本地开发机为Windows,编译机为Linux,两者使用Samba进行文件互传。

在Windows电脑上直接打开以上生成的Android Studio工程是不行的,会直接闪退,因为其中的路径都是Linux下以/开头的路径,并不能被Windows识别。

以下是修改步骤:

  1. .idea/modules.xml

原本的配置:

<module fileurl="file:///$PROJECT_DIR$/frameworks.iml" filepath="$PROJECT_DIR$/frameworks.iml" />
<module fileurl="file:///$PROJECT_DIR$/dependencies.iml" filepath="$PROJECT_DIR$/dependencies.iml" />
<module fileurl="file:data/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/base/framework_srcjars.iml" filepath="/data/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/base/framework_srcjars.iml" />
<module fileurl="file:data/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/frameworks.iml" filepath="/data/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/frameworks.iml" />

需要改成如下配置:

<module fileurl="file://$PROJECT_DIR$/frameworks.iml" filepath="$PROJECT_DIR$/frameworks.iml" />  
<module fileurl="file://$PROJECT_DIR$/dependencies.iml" filepath="$PROJECT_DIR$/dependencies.iml" />  
<module fileurl="file://Z:/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/base/framework_srcjars.iml" filepath="Z:/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/base/framework_srcjars.iml" />  
<module fileurl="file://Z:/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/frameworks.iml" filepath="Z:/code/roc_rk3588s_pc/Android12.0/RK3588_Android12.0/frameworks/frameworks.iml" />

首先需要将/data/code/roc_rk3588s_pc替换成Z:/code/roc_rk3588s_pc,其次特别需要注意的是Linux下是file:data/code/roc_rk3588s_pc形式,而Windows下需要是file://Z:/code/roc_rk3588s_pc形式,区别是Linux下的file:后面是三个/随后跟着路径,而Windows下需要是file:后面是两个/随后跟着路径。

  1. .idea/vsc.xml
<mapping directory="$PROJECT_DIR$" vcs="Git" />

如果是以file:开头的路径,也要注意从Linux下转换成Windows下的形式。

  1. dependencies.iml 和 frameworks.iml

这两个文件在frameworks目录下,用于列举Java源码的目录。

只需要将/data/code/roc_rk3588s_pc替换成Z:/code/roc_rk3588s_pc即可。

至此,路径替换完成,可以使用Windows下的Android Studio打开Samba的frameworks目录,打开后注意Project SDK选择JDK,不能选Android SDK,因为我们就是需要修改本地工程的这部分代码,JDK的版本可以参考prebuilts/jdk下面的JDK版本,对于Android12可以选择JDK11。

然后等待Android Studio索引完毕吧!

标签:--,配置,aidegen,idea,Framework,Studio,Android,IDE
From: https://blog.csdn.net/2401_85111291/article/details/139309285

相关文章

  • 浅谈SpringBoot配置文件
    文章目录一、配置文件作用二、配置文件分类三、SpringBoot内置的配置文件格式3.1、.properties3.1.1、.properties配置语法3.1.2、.properties读取方式3.2、.yml/.yaml3.2.1、.yml配置语法3.2.2、.yml读取形式四、两种配置文件优缺点4.1、.properties4.2、.yml4.2.1、......
  • [论文速览] Design and Development of a Framework For Stroke-Based Handwritten Gu
    1.Pretitle:DesignandDevelopmentofaFrameworkForStroke-BasedHandwrittenGujaratiFontGenerationsource:arXiv2024paper:https://arxiv.org/abs/2404.03277code:None关键词:fontgeneration,handwritten,gujarati,stroke阅读理由:刷新鲜论文ing2.Mo......
  • VMware虚拟机中Centos最小化安装后的常用配置
    每次在虚拟机安装linux之后都要配置固定ip,安装docker等操作,所以使用此文章,记录以后快速配置1.设置静态IP设置静态ip前,如果没有配置过虚拟机网络的,先进行如下配置:关于VMwareWorkstationPro中虚拟机无法连接外网问题解决在虚拟机界面,配置静态IP,方便使用shell工具进行......
  • cmake配置VS工程配置使用dll
    cmake配置VS工程配置使用dllAuthor:ChrisZZTime:2024-06-0116:17:04目录cmake配置VS工程配置使用dll1.目的2.如果找不到dll,会发生什么?3.需要找到哪些dll?3.1“就那么几个文件,手动拷贝“3.2从依赖树递归查询3.3额外的dll文件4.找到dll后放到哪里?4.1VS工程属性......
  • 配置开发环境、生成环境、测试环境
    在项目开发部署的过程中,一般都会有三套项目环境Development:开发环境Production:生产环境Test:测试环境例如:开发环境的mysql连接的是本地,生产环境需要连接线上的mysql环境 打开我们的后端项目,基于原来的application.yml文件再创建三个文件,命名如下:application-dev.yml......
  • Android/iOS 应用内评价功能
    应用内评价,即应用中就能拉起对应商店的对应App的评价窗口,而无需用户到商店App内评价目前整理到有应用内评价功能的平台:Android-GooglePlayiOS-AppleStoreAndroid-GooglePlay应用内评价publicinterfaceGooglePlayFlowListener{voidOnCompleteListener();......
  • AndroidStudio资料
    AndroidStudio导入jar包  Switch语句报错Constantexpressionrequired   AndroidStudio中怎样引用图片资源   新版本Logcat使用详解java反编译jar包并修改class重新打包   Jar包反编译后修改源码再编译java.lang.NoClassDefFoundError:Failedresolutionof:......
  • 消费者与提供者引用配置
    dubbo配置项手册提供者暴露服务配置org.apache.dubbo.config.ServiceConfiginterface:服务接口名ref:服务对象实现引用version:服务版本,建议使用两位数字版本,如:1.0group:服务分组,当一个接口有多个实现,可以用分组区分delay:延迟注册服务时间(毫秒),设为-1时,表示延迟到Spring容器......
  • Kafka安装配置及Java中的使用
    目录一、消息队列二、流派分类:三、Kafka基本介绍四、主题和分区的概念五、Kafka集群六、kafka-clients之生产者七、kafka-clients之消费者八、SpringBoot使用Kafka九、Kafka集群中的controller、rebalance、HW(1)controller(2)rebalance机制(3)HW和LEO十、Kafka问题优化......
  • mysql数据库8.4免安装方法配置
    在执行以下操作时,先把以前的data删除,移除相关服务后再进行操作。netstopmysqlmysqld--remove【简单安装,且操作不复杂】#1、根目录下新建my.ini[mysqld]basedir=C:/mysqldatadir=C:/mysql/dataport=3306#2、空密码初始化mysqld--initialize-insecure--user=mysql--conso......