IntelliJ IDEA: Cannot import SBT project

末鹿安然 提交于 2019-11-29 03:27:19

I had this error when importing a new module from existing sources.

  • On the right-hand side of your IntelliJ window, you will see a list of vertical tabs, open the SBT tab.
  • Select the module that's causing trouble, right click on it, select "Detach external project"
  • Try to import the module again.
  1. Move to /your-project-folder
  2. Run ./activator
  3. Type idea . It will generate IDEA project.
  4. Open (not import) File->Open.. project in IDEA.

I encountered the same error when I was trying to import a new scala project A to an existing IntelliJ project B as a module. I solved the problem by following step below:

  1. Go to your folder of project B. Open file .idea/sbt.xml.
  2. Deleting the entry which includes the path of project A.

After a series of struggles, I must say something weird solved this problem – moving to IntelliJ IDEA Ultimate. That has built in Play application support and can run/debug/test the application out of the box, which is very handy.

All I can say after this experience was that JetBrains wants you to upgrade to Ultimate if you want things to work right out of the box.

I'm sure there are ways to get this working with CE also, but I wasn't successful with that.

  1. Uninstall everything
  2. Reinstall IntelliJ
  3. Install the JetBrains official Scala plugin
  4. Import the project

    • Make sure that the project has a build.sbt file in the right place, so that IntelliJ can find it as an SBT project.
    • This is about IntelliJ IDEA version 13.1.4.

I had a similar problem which came from a different place than the other solutions here so adding it in case it occurs for others.

In my case the problem was caused by accidentally opening the IdeaProjects directory. When you do this, it creates the .Idea folder in that directory, and populates it as a project. This apparently also confuses the set import.

The solution is to remove the .Idea folder and open (not import) the directory again.

This issue is solved in the latest updates of the SBT and Scala plugins.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!