IDE中检查Hyperskill练习答案时Gradle启动失败求助
解决Hyperskill练习检查时Gradle启动失败的问题
问题描述
在IDE中检查Hyperskill练习答案时,Gradle执行报错:
Failed to launch checking
FAILURE: Build failed with an exception.
- 问题原因:Gradle could not start your build.
详细异常:
Cannot create service of type BuildTreeActionExecutor using method LauncherServices$ToolingBuildTreeScopeServices.createActionExecutor() as there is a problem with parameter #18 of type List.
Could not create service of type ConfigurationCacheProblems.io/usethesource/capsule/Set$Immutable
已尝试切换Gradle依赖分支(release→master)、清除缓存、重启IDEA/电脑、更换Java版本,问题仍未解决。
解决方案
1. 强制指定Gradle版本并排除冲突依赖
在项目的build.gradle(或build.gradle.kts)中,明确指定兼容的Gradle版本,并排除可能引发冲突的capsule依赖:
// Groovy DSL示例 buildscript { repositories { mavenCentral() } dependencies { classpath 'org.gradle:gradle-wrapper:7.6' // 选用7.x系列稳定版本 // 排除Hyperskill插件中的capsule依赖 classpath('com.hyperskill:hyperskill-gradle-plugin:latest.release') { exclude group: 'io.usethesource.capsule' } } } // 全局排除所有capsule依赖 configurations.all { exclude group: 'io.usethesource.capsule' }
2. 手动添加缺失的capsule依赖
如果排除冲突后仍出现类找不到的问题,直接在依赖中补充缺失的库:
dependencies { implementation 'io.usethesource.capsule:capsule:0.7.1' }
3. 重置Hyperskill插件
- 打开IDEA设置(File → Settings → Plugins)
- 找到Hyperskill插件,点击「Uninstall」卸载
- 重启IDEA后重新安装插件
- 重新关联Hyperskill练习项目
4. 彻底清理Gradle缓存并同步
执行命令清理本地Gradle缓存:
# Mac/Linux rm -rf ~/.gradle/caches/ # Windows del /s /q %USERPROFILE%\.gradle\caches\
回到IDE执行「File → Sync Project with Gradle Files」重新同步项目。
5. 检查Gradle Wrapper配置
打开项目根目录下的gradle/wrapper/gradle-wrapper.properties,确保distributionUrl指向稳定兼容的Gradle版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
避免使用过新或过旧的版本,优先选择与Hyperskill插件匹配的版本。
内容的提问来源于stack exchange,提问作者Mahsa Rohani
相关产品推荐
相关产品推荐

