You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编译IntelliJ IDEA源码报错:包未找到及符号无法解析

编译IntelliJ IDEA源码时的commons-lang依赖问题及解决办法

问题现象

编译报错

/home/youssef/intellij-community/android/as-driver/utils/testSrc/com/android/tools/asdriver/tests/XvfbServer.java:26:31
java: package org.apache.commons.lang does not exist

/home/youssef/intellij-community/android/as-driver/utils/testSrc/com/android/tools/asdriver/tests/XvfbServer.java:85:10
java: cannot find symbol
  symbol:   variable SystemUtils
  location: class com.android.tools.asdriver.tests.XvfbServer

多模块无效依赖

-Module intellij.android.core: invalid item 'commons-lang' in the dependencies list
-Module intellij.android.as-driver.utils: invalid item 'commons-lang' in the dependencies list
-Module intellij.android.glance-designer: invalid item 'commons-lang' in the dependencies list
-Module intellij.android.studio.integration: invalid item 'commons-lang' in the dependencies list
-Module intellij.android.compose-designer.tests: invalid item 'commons-lang' in the dependencies list
-Module android.sdktools.db-compiler: invalid item 'commons-lang' in the dependencies list

前置问题(已解决)

此前执行getPlugins.sh脚本时遇到以下Git错误,已自行解决:

fatal: read error: Connection reset by peer
fatal: early EOF
fatal: index-pack failed

问题原因

  • 依赖未正确拉取:模块配置中声明了commons-lang依赖,但构建系统未成功获取到该依赖包,导致编译时找不到对应类和包。
  • 依赖版本不兼容:commons-lang为已废弃的旧版本依赖,部分模块可能误用了旧包路径,或依赖坐标配置错误,无法被正常解析。
  • 前置Git问题残留影响:之前的脚本执行异常可能导致部分依赖仓库或子模块未完全拉取,间接引发依赖缺失。

解决步骤

  • 重新同步依赖并刷新项目
    在IntelliJ IDEA中执行File -> Sync Project with Gradle Files,或在项目根目录终端运行:

    ./gradlew clean build --refresh-dependencies
    

    强制刷新依赖并重新构建。

  • 修正依赖坐标与代码导入
    若模块误用了旧版commons-lang,需替换为仍在维护的commons-lang3:

    1. 修改代码中的导入语句,将import org.apache.commons.lang.SystemUtils;替换为import org.apache.commons.lang3.SystemUtils;
    2. 在模块的Gradle配置中,将commons-lang依赖替换为commons-lang3的正确坐标,例如:
      implementation 'org.apache.commons:commons-lang3:3.12.0'
      
  • 重新执行依赖拉取脚本
    重新运行./getPlugins.sh,确保所有子模块和依赖仓库完整拉取,避免遗漏依赖配置。

  • 清理缓存后重建

    1. 清理IntelliJ IDEA缓存:执行File -> Invalidate Caches... -> Invalidate and Restart
    2. 清理Gradle缓存:删除~/.gradle/caches目录,或运行./gradlew clean
    3. 重新执行构建命令,确认问题是否解决。

内容的提问来源于stack exchange,提问作者youssef gamal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 05:33:25