编译Android Studio 2024.2.1源码失败:缺失指定插件模块
在Pop!_OS 22.04 LTS x86_64环境下,编译Android Studio 2024.2.1源码执行tools/idea/build_studio.sh时,触发以下错误:
java.lang.IllegalStateException: The following modules from productProperties.productLayout.bundledPluginModules aren't found in the project: [intellij.c.clangd.plugin, intellij.c.clangdBridge.plugin, intellij.c.plugin, intellij.cidr.debugger.plugin, intellij.cidr.base.plugin, intellij.cidr.clangConfig.plugin, intellij.cidr.clangFormat.plugin, intellij.rml.dfa.plugin]
官方文档未提及这些插件的安装步骤,且IntelliJ IDEA编译说明已过时,未覆盖该依赖问题。以下是可行的解决步骤:
1. 同步对应版本的IntelliJ插件源码
Android Studio依赖JetBrains IntelliJ的C/C++相关插件模块,需拉取匹配版本的源码:
- 进入源码根目录下的
tools/idea文件夹 - 执行命令添加仓库并同步对应分支(替换
242.xxxx为Android Studio 2024.2.1基础IntelliJ版本号,可在Studio的「关于」页面查看):
git remote add intellij https://github.com/JetBrains/intellij-community.git git fetch intellij refs/heads/242.xxxx:refs/remotes/intellij/242.xxxx git merge intellij/242.xxxx --no-commit --no-ff
2. 临时排除未找到的模块(无需C/C++功能时用)
如果不需要Android Studio的C/C++开发支持,可修改编译配置跳过这些模块:
- 打开
tools/idea/build/android_studio_build_target.kt文件 - 找到
productProperties.productLayout.bundledPluginModules配置项,移除报错列表中的所有模块 - 保存后重新执行
tools/idea/build_studio.sh
3. 安装系统编译依赖
确保系统已安装C系插件编译所需的基础依赖:
sudo apt update && sudo apt install -y clang llvm libclang-dev build-essential
4. 重置构建环境
清理缓存并重新初始化构建环境:
./gradlew clean ./gradlew :studio:prepare
内容的提问来源于stack exchange,提问作者Liam Clink

