模块... 没有梯度支撑

我使用的是 IntelliJ IDEA Pro 13.1.2,从未使用过低于13的版本。

当试图从 IDE 运行 build.gradle时,我得到了这样的信息:

模块没有梯度支撑

我可以在命令行中运行这个脚本。

“ root”目录有 .gradlegradle两个子目录,一般来说,它的结构与来自同一个项目的另一个模块非常相似,在这个模块中,我可以毫无问题地从 IDE 运行它的构建。

对进一步的故障排除有什么建议吗?

90563 次浏览

If you didn't set up the IDE project via "Import Project" and then pointing to a Gradle project, you may have to link the IDE project to the Gradle project. This can be done in the "Gradle" window.

For a non-gradle project, you can also remove the module from the project and re-import it. This will help avoid the message "module is not backed by gradle".

Tools > Grails > Change SDK Version

I fixed this problem by clicking in the Menu

--> "Run"
--> "Edit Configurations"
--> [+] The little plus in the top left corner
--> "Gradle"

With the new created run configuration it worked. I hope this will help some of you.

The answer that worked for me is to restart IntelliJ - at startup build.gradle is identified and the project is set up.

The only thing that worked for me was to use the menu File > Close Project and reopen it. IDEA popped up a dialog saying "Import project from Gradle files" or something to that effect.


Dead ends: Below is a list of dead ends, so don't waste your time with them. I kept seeing "module is not backed by gradle" despite following all these proposed solutions:

  1. There was no Gradle tool window, so I couldn't synchronize the project
  2. Clicking File > Open gradle.build opens the file for editing and doesn't solve the issue
  3. Creating a run configuration that runs gradle has no effect, even after I saw a build/ folder created
  4. Runing ./gradlew from the commandline only creates files for gradle and doesn't fix IntelliJ

I'm using android studio, intellij. Try this:

  • Tools > Android > (sync project with gradle files)
  • Run gradle build

Like others have said, none of the other answers worked for me. The only thing that worked was:

Close the project, then import it as a Gradle project.

  1. Do not select the project directory when importing
  2. Select the gradle file to import as a Gradle project
  3. I always use Local Gradle Distribution and Offline work to build, then switch back.
  4. It will auto build and you will see the gradle task in task window.

Hope it works for you.

This problem happened for me because I chose a different name for my project than my artifactID. In order to prevent this problem to happen, make sure your project name is the same as your artifactID.

You may have originally created the project via File->New->Project From Version Control. This doesn't seem to always set the project up as a Gradle project, even if there is a build.gradle in the root directory. To solve this:-

  1. Close IntelliJ.
  2. Delete the .idea folder in the project.
  3. Start IntelliJ and select 'Open'.
  4. Navigate to the project folder and open it.

The project will be recognised as Gradle and be set up as such.