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

添加idea插件后评估:app项目时出现Value is null错误

Gradle配置idea插件时出现"Value is null"错误的解决办法

环境信息

  • IntelliJ IDEA 2022.2(社区版)
  • Java 8

错误场景

在build.gradle中配置了如下内容:

plugins {
    id 'application'
    id "com.nocwriter.runsql" version "1.0.3"
    id 'idea'
    id "io.spring.dependency-management" version "1.0.11.RELEASE"
}
apply plugin: "io.spring.dependency-management"

group = 'com.myproject'
version = '2.0.6'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

idea {
    project {
        languageLevel = JavaVersion.VERSION_1_8
    }
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

执行构建时,在project {所在行(第31行)触发错误,错误信息如下:

FAILURE: Build failed with an exception.

  • Where:
    Build file '/myproject/app/build.gradle' line: 31

  • What went wrong:
    A problem occurred evaluating project ':app'.

Value is null

解决方法

1. 替换idea.project配置方式

idea.project块的配置容易因上下文模型实例缺失报错,直接通过编译任务设置语言级别即可达到同样效果,保留idea.module的配置:

plugins {
    id 'application'
    id "com.nocwriter.runsql" version "1.0.3"
    id 'idea'
    id "io.spring.dependency-management" version "1.0.11.RELEASE"
}
apply plugin: "io.spring.dependency-management"

group = 'com.myproject'
version = '2.0.6'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

// 直接通过编译任务设置语言级别,替代idea.project块
tasks.withType(JavaCompile) {
    options.compilerArgs += ['-source', '1.8', '-target', '1.8']
}

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

2. 检查Gradle版本兼容性

Java 8仅支持Gradle 6.x、7.x版本,如果你用的是Gradle 8+版本,会出现兼容性问题,建议降级到Gradle 7.6.x版本(最后支持Java8的Gradle版本),同时确保Gradle版本与IDEA内置的Gradle插件版本匹配。

3. 清理Gradle缓存并重新同步

执行以下命令清理缓存,再重新同步项目:

./gradlew clean build --refresh-dependencies

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 15:24:25