Play Framework & IntelliJ - Cannot resolve symbol index/routes - intellij-idea

I'm new to playframework/intellij and I have finally managed to import a play-java-intro succesfully (yey!), but when I try to edit the Application.java file, I see the error shown in the picture below "Cannot resolve symbol index" and "Cannot resolve symbol routes".
What does this mean? How do I get rid of these errors/warnings?
I have tried to run the program aswell to see if it works, and the project works. This means that the errors are showing false.
Also, how do I refresh the project in IntelliJ? I once managed to do this, but that was after a popup came in the topright corner. I have never managed to find the refresh button after that. Just a "Synchronize Project", which does nothing.

Do as following:
1- In intelliJ navigate to Project Structure > Modules
2- In the sources tab find target > scala_2.11 > src_managed > main and click on it.
3- Mark in as 'Sources' by clicking the button on top of browsing pane.
4- Click OK
That should be it.

I was having a similar issue and I Have updated my IntelliJ to version 2017.3 and everything is working fine now.

In Intellij 2022 try running sbt run once and hit the url (e.g localhost:9000) .
Tested on Play official samples

Related

Error: Cannot find entry file ./node_modules/react-native-scripts/build/bin/crna-entry.js in any of the roots:

I keep receiving this error when running my App.js for React Native that was working perfectly well before I attempted installing Victory charts. Somehow something broke and after over three hours of work I am unable to figure out a solution. I have tried everything I could find on the web including uninstalling watchman, reinstalling watchman, reverting to React Native 0.55.4, some other recommended commands. Nothing is working.I am so confused.
$ yarn add react-native-scripts
This helped.
I think the other library may hurt the installation part of your package. To solve this issue on IOS you need to add its library like below:
First do 'yarn add react-native-scripts'. In the case that it dose't work continue other steps.
1-Go to the node module of your project and find the package folder and find the ios file inside it.
2- Then drag it into ‘library’ section of your xcode. (It is the subset of your project folders)
3- Then go to ‘build phase’ and in the ‘Link binary with libraries’ add it there by clicking on the plus sign
4- Then in some cases you need to add the correct path of the ios file inside your node module in the xcode. To do that you should go to ‘build setting’ section in the xcode and search header there. Then you need to add the path there below other paths.
5- Then clear everything (cmd+shift+k) and then finally compile it.
I hope it works for you.
In my case the "crna-entry.js" file does exist in the roots and my project should work (nothing have been modified from last time when it does work).
After hours searching, finally I figured out the reason:
the packager's directory checking is case-sensitive and in windows terminal the drive "c:/" will not be auto-corrected to "C:/" which will lead to error.
Hope this will help someone who gets the same error.
Below is the full error message:
The development server returned response error code:404 Cannot find
entry file node_modules/react-native-scripts/build/bin/crna-entry.js
in any of the roots:

intellij IDEA - Edit Configuration

I installed IntelliJ IDEA with Java10.
I am having troubles with the build and run. I am being asked to edit the configuration.
I have specified the JDK 10 in the module settings. Is that a bug ?
And, I get this error when I try to compile with a random configuration setting.
Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException:
this part is really confusing and not really user-friendly and well documented by JetBrain I find
Right mouse click on the code window and select Run Your_file_name.kt
It will show you the green button to run the script instantly like below screenshot. click on that button.

Not able to show image (API setDrawIcons() not found error)

I am using MPAndroidChart in our android project to show graph and it's very helpful. Using latest version 3.0.1 (https://github.com/PhilJay/MPAndroidChart#usage)
I have some requirement to show image on top of BarEntry after some condition met. Same is working in example code downloaded.
BarDataSet set1;
set1.setDrawIcons(true);// Cannot resolve method 'setDrawIcons(boolen)
Why the above API is not part of library MPChartLib, am I missing something here?
Above problem got solved after integrating MPChartLib source code.
File -> Project Structure
click plus button to add New Module
Import Gradle Project
from Source directory: and finish.
The setDrawIcons method was added in 3.0.2. Change your Gradle option to read compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'

intellij "object index is not a member of package views.html"

I've got Intellij 15.0.5 and I cannot get rid of this error
object index is not a member of package views.
I've created a new play project in Intellij and also using the activator command
activator new PlayTestProject
But I keep getting the above error. I've read all the other similar question on SO but none of them helped and I've tried the following
Right click the project -> Add framework support -> select "Play 2"
Result: I didn't see any change to my project. When I hit OK, the window disappears but if I try the same the second time. Nothing happens and the window is still there!
Preferences -> Languages & Frameworks -> Play2 -> select "Use Play 2 compiler for this project"
Result: I get this error
Error:Module 'client' production: java.lang.NullPointerException
I've tried
invalidate cache & restart
sbt clean
checkout a fresh new project
But I keep getting the same error in Intellij.
Running sbt compile on command line runs the build successful. But Intellij keeps shows me the above error.
How do I fix this ?
Alright if anyone is running into the same problem. The fix was to mark the following two directories as Sources Roots in Intellij.
/target/twirl/main
/target/routes
Steps:
Right click the target folder -> Mark directory as -> Cancel exclusion (If you don't see Cancel exclusion do the next step.
Right click the target/scala-2.11/twirl/main folder -> Mark directory as -> Sources Root
Right click the target/scala-2.11/routes folder -> Mark directory as -> Sources Root
Right click the project Open module settings -> Sources -> and remove the above two directories if there are added in the Excluded folder's section.
This fixed my problem.
I found this problem and it appeared to be caused by an incomplete compile within sbt. (I had done "sbt clean ; sbt compile" but then aborted the compile with Ctrl+C because it had a error.)
Intellij worked correctly again after I ran:
sbt clean
After removing the .idea/ folder, I could successfully re-open/import my project, and the errors were gone.
Just remove the #() from top of index.scala.html because there are no parameters.
#()
<!DOCTYPE html>
<html lang="en">
And in Action you have
def index = Action {
Ok(views.html.index())
}
I had a similar error and just had to run npm install to fetch the necessary dependencies. Listing it here in case anyone has the same issue.

Cannot resolve method 'ok(?)' with Play 2 Framework in Intellij

I have been trying to get play set up in IntelliJ for hours but I can't get it to work correctly.
I continuously get this error: http://imgur.com/MYY8fXI
I have tried create a project though the terminal with:
play new
and then using the terminal to create the idea files with
idea with-sources=yes
I have also installed the play 2 plugin and used it to create the project, but I get the same error.
I am able to use the plugin I downloaded to successfully run the app and view it in my browser, but I keep getting the
Cannot resolve method 'ok(?)' error.
edit: I am using OSX, and have the ultimate version of Intellij.
edit 2: I have made a little progress. If I import the view directly using import views.html.index; it gets rid of the errors on the application. However, if I use import views.html.*; it results in the errors. Any ideas?
At the time of this writing, it seems that play2 support in IntelliJ 13 Ultimate has some minor problems...
How I did solve the issues:
1) Navigate to your project director and start your play console (play.bat / play.sh should be on the PATH)
2) enter command 'compile' in your play console
3) enter command 'idea" in your play console
4a) in case your IntelliJ project was alread open, IntelliJ will detect the changes and suggest to reload the project. Confirm you want to reload
4b) in case IntelliJ was not running, open the project by File | Open... and select your project Directory.
These steps should resolve your issue.
Does it help to make sure that play has compiled the templates to class files, 'run' + open in browser or 'compile'?