19

I'm completely new to development using Play or IntelliJ for that matter. I've created a simple HelloWorld application using Activator, and this is an sbt project.

I've been trying to import this to IntelliJ and this is the screen I'm stuck at: https://www.dropbox.com/s/we1a4a3184sojvb/Screenshot%202014-07-24%2016.57.11.png

In almost all tutorials I've been through online, I've seen people using an sbt option on the import screen. I've installed the SBT plugin as well, but that hasn't helped. I've restarted IntelliJ several times to no avail.

Where am I going wrong? I'm running 13.1.4 with the SBT plugin installed.

Ashesh
  • 2,978
  • 4
  • 27
  • 47
  • 2
    If you have Scala plugin installed you should be able to just open the project, without using import facility. – lpiepiora Jul 24 '14 at 15:15
  • maybe the generated project doesnt have build.sbt file, so import project will stuck like that. Normally, activator idea can fix it, also there are some templates of activator have already have build.sbt file. – Xiaohe Dong Jul 25 '14 at 13:59
  • You have to install Scala plugin. It has SBT and play2 support. [Look here](http://stackoverflow.com/a/4254253/5686654) – Artem Jan 15 '16 at 10:34
  • What was in that screenshot? It's not there any more. – Don Branson Oct 17 '18 at 20:10

9 Answers9

38

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.
Zoltán
  • 21,321
  • 14
  • 93
  • 134
9
  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.
red1ynx
  • 3,639
  • 1
  • 18
  • 23
  • I've done that but I'm afraid its still quite broken. I cannot resolve classes, for example, `WS.Response` cannot be resolved. Its really strange. Maybe switching from Typesafe Activator to just plain-jane Play will help. – Ashesh Jul 28 '14 at 10:32
  • Try `sbt idea with-sources=yes` – red1ynx Jul 29 '14 at 11:24
5

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.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
4

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.
sma
  • 877
  • 2
  • 9
  • 24
  • 1
    This also solved my problem. I initially tried to use version 2020.1.2 - Ultimate. For some weird reason it didn't work. When moving back to the same version but the CE release, it stopped working. Removing the `.idea` folder solved my problem for good. – Dr. Vick Jun 26 '20 at 00:28
2

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.

Ashesh
  • 2,978
  • 4
  • 27
  • 47
  • 2
    I use IntelliJ Ultimate and I have the same problem (though not using sbt nor Scala, but Gradle and Java). So, no: The problem also exists for the ultimate edition. – OlliP Jul 30 '19 at 07:34
  • +1 to @OlliP, I have reproduced the same issue using Spring Initialzr for basic Spring Boot project and when I open this project inside Intelij IDEA. After several attempts, I've succeeded with it and IDEA loaded all dependencies. – invzbl3 Jul 20 '20 at 18:08
1

Solved for

IntelliJ IDEA 2022.2.1 (Ultimate Edition)
scala plugin: 2022.2.12
sbt version: 1.7.1

doing these steps:

  1. Unlink sbt Project(sbt toolbar), then link it again.
  2. Delete modules (ctrl + alt + shift + s).
  3. Remove .bsp/, and .idea/ config files.
  4. Invalidate caches..(ctrl + f).
  5. Restart IDEA.

The number of steps to make it work may vary.

Alex_Gofman
  • 117
  • 1
  • 6
0
  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.
Ryoichiro Oka
  • 1,949
  • 2
  • 13
  • 20
  • I've done that. And I'm currently on IntelliJ IDEA 13.1.4 but it just doesn't work. I've also installed all the plugins already. https://www.dropbox.com/s/zncnc2udwxe73rs/Screenshot%202014-07-28%2012.30.15.png – Ashesh Jul 28 '14 at 10:29
  • Then I think the reason is because the project that you're trying to import doesn't have a `build.sbt` file as @Cloudtech is saying. IntelliJ recognizes an SBT project when it finds out the build file inside of the project's folder, not by finding out `.scala` files. So just make a new file in the project naming it `build.sbt`, maybe writing some contents in it, then try again. Hope it works this time! I edited my answer including this tip. – Ryoichiro Oka Jul 28 '14 at 16:52
0

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

DanielDiSu
  • 1,139
  • 1
  • 11
  • 10
0

Make sure that your java path is correct (IntelliJ can use other path than system defined)

Preferences -> Build, Execution, Deployment -> sbt -> JVM - choose a correct JRE

tgdavies
  • 10,307
  • 4
  • 35
  • 40