Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol 'play' error with Play Framework 2.4.x and IntellijIdea 14.x

I've created a Play-java [v 2.4.2] project with using activator[v 1.3.5] that uses JDK 1.8 on Windows 64-bit OS. I've run activator run command and it works smoothly.

But when I open that project in Intellij Idea [v 14.1.4] IDE not working properly; warns me in controller and view files as follows: Intellij IDEA 14.x controller

and this:

Intellij IDEA 14.x view

And it says: 'Cannot resolve symbol ...'

I googled this and find some useful links, included a few stackoverflow Q&A's, i.e: Play framework tutorial: Cannot resolve symbol 'index'?

I've Scala and Play plugins and in this path ([File -> Project Structure -> Modules -> [MyAppModule] -> Sources Tab]) there is no "target/scala-[version]/src_managed" directory. Look this:

Intellij IDEA 14.x project structure

In this Intellij Idea or Play version, something's changed.

I've tried some combinations for making folders as source folder or excluded. I've used IDE's option: 'Invalidate Caches/Restart'. None of them worked for me.

How can I fix this issue?

like image 860
Oguz Ozkeroglu Avatar asked Aug 14 '15 08:08

Oguz Ozkeroglu


2 Answers

Finally I've got the solution. Here are the steps that I followed:

  • Create a play-java project using activator.
  • Import that project as an SBT project to Intellij Idea.
  • Right click on project then select "Add Framework Support" and then select "Play 2.x"
  • Build -> make project.

Now everything works fine.

like image 87
Oguz Ozkeroglu Avatar answered Nov 13 '22 03:11

Oguz Ozkeroglu


For play project, you have to let Intellij know this is a SBT project.

File -> Open -> select the .sbt file under the root directory of your project. It will take Intellij a while to resolve the project and download dependencies.

In addition, from my personal experience, you should use activator new to create a new Play project and import that project into Intellij rather than directly creating a Play project usingn Intellij Play plugin. Sometimes, the plugin does not work properly.

like image 21
Luong Ba Linh Avatar answered Nov 13 '22 03:11

Luong Ba Linh