IntelliJ IDEA "cannot resolve symbol" and "cannot resolve method" - intellij-idea

What are common causes for IntelliJ IDEA not being able to resolve built-in JVM types and methods? For example, when I mouse over String the tooltip says "Cannot resolve symbol 'String'". It's as if IntelliJ has doesn't know where the JVM is.
By the way, I am running OS X 10.6.6. Everything was working fine until I ran the system update this morning.

Most likely JDK configuration is not valid, try to remove and add the JDK again as I've described in the related question here.

First check if you have configured JDK correctly:
Go to File->Project Structure -> SDKs
your JDK home path should be something like this:
/Library/Java/JavaVirtualMachine/jdk.1.7.0_79.jdk/Contents/Home
Hit Apply and then OK
Secondly check if you have provided in path in Library's section
Go to File->Project Structure -> Libraries
Hit the + button
Add the path to your src folder
Hit Apply and then OK
This should fix the problem

I was facing the same problem when import projects into IntelliJ.
for in my case first, check SDK details and check you have configured JDK correctly or not.
Go to File-> Project Structure-> platform Settings-> SDKs
Check your JDK is correct or not.
Next, I Removed project from IntelliJ and delete all IntelliJ and IDE related files and folder from the project folder (.idea, .settings, .classpath, dependency-reduced-pom). Also, delete the target folder and re-import the project.
The above solution worked in my case.

For me, I had to remove the intellij internal sdk and started to use my local sdk. When I started to use the internal, the error was gone.

I tried almost everything but nothing was helping with the ibm jdk 1.8. to fix this issue. then I found an article from https://youtrack.jetbrains.com/issue/IDEA-279214/Cannot-resolve-symbol-String-when-using-IBM-JDK-180 and it worked like charm!!!
so sharing original help credit goes to #Serge Barano. incase anybody needs and not able to able to resolve the issue using previous solutions like me.
according to the article answer is:
IBM JDK has a weird layout and the jar with the String class is in bin directory for some reason:
d:\dev\ibm_sdk80\jre\bin\default\jclSC180\vm.jar
If you add it to the JDK classpath in IntelliJ IDEA, the issue should resolve:

For me, IntelliJ could autocomplete packages, but never seemed to admit there were actual classes at any level of the hierarchy. Neither re-choosing the SDK nor re-creating the project seemed to fix it.
What did fix it was to delete the per-user IDEA directory ( in my case ~/.IntelliJIdea2017.1/) which meant losing all my other customizations... But at least it made the issue go away.

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

For me ,
File -> project structure -> Project Language Level (11) selection worked. Local variable syntax for lambda paramters.

In my case, cloning repo from the remote was the easiest way to solve this issue.

Related

Could not create parent directory for lock file C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\

I'm relatively new to IntelliJ. I'm using IntelliJ IDEA 2019.2.4.
When I try to do an Import From Existing Source - I get the following error:
Could not create parent directory for lock file C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\jbr\bin\proxy\wrapper\dists\gradle-5.3-all\b2xqo51qjs5t4spu8wb5tlf15\gradle-5.3-all.zip.lck
That's new - I didn't used to get that.
Any suggestions?
Thanks much
This issue has been discussed by another already (in Android Studio) but I will quickly summarize the issue as it should be quite similar using IntelliJ. Thanks to Mike Hill this will remedy your problem. Here is his answer Could not create parent directory for lock file
The issue you discussed appears to have been caused by using the "Use gradle 'wrapper' task configuration" option in IntelliJ..this option causes IntelliJ to override the Gradle wrapper task (which is sort of expected).
The solution that Mike Hill suggests is to select "Use default gradle wrapper (recommended)" instead. Seems that this caused a conflict with the customized GRADLE_USER_HOME environment variable in IntelliJ for the directory where the final wrapper files actually get stored.
He then provides an absolute path example which may be what is throwing the error for you as well.
Gradle was trying (and failing) to create C:\ProgramData\chocolatey\lib\gradle\tools\gradle-4.5.1\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when run through IntelliJ, although his system uses the file C:\work.gradle\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when working correctly.
Switching and then running the Gradle refresh through IntelliJ seems to have fixed it for Mike. It also succeeds when switching back to "Use gradle 'wrapper' task configuration", now. Hopefully this helps you out Tim!
I did hours of research and I discovered that the localhost:8080 on my program had never fully detached last time I stopped running the program. The program refused to start because really it never stopped from last time. Detach you localhost. If you don't know how just restart the computer--it will detach everything
Encountered on Mac.
Seems like a bug in IntelliJ IDEA.
Changing Gradle user home from ~/.gradle
to an absolute path /Users/username/.gradle has actually helped

IntelliJ + Play Framework routes file red underline error

Image of the errors
I don't how to fix this red underlines I recently got in my routes files.
What I did:
I split up my routes files into 3 files:
- routes
- rest.routes
- web.routes
And after I did, IntelliJ said something about "We have a new program that can handle .routes files" and I clicked yes to it. <-- Stupid me :(
Can also mention that I cant remember what addon that was installed, and I cant find any addons that differs from previous versions.
Before there was no "spellchecking" on the file, but now I get this box in top of the file saying "Project SDK is not defined 'Setup SDK' ". It also gives the red "undelining" similar to spellchecking under every single line of code in the file.
The code itself works great, its just very frustrating to have these red lines everywhere.
Anyone know how to get rid of it?
Highly appreciated!
IntelliJ 2017.2 and Play Framework 1, I had this problem one day. Took me awhile to figure out but it was the Scala plugin that made this fail for me. After uninstalling the Scala plugin it works again.
I also faced similar issue recently. The plugin that Intellij asks to install in this case is Erlang. You just have to uninstall it (or just suppress the warning).
To uninstall Erlang go to Preferences.. -> Plugins. Then search for Erlang and select. Then click uninstall (on the right pane).
First, setup Java SDK (even if you use scala)
Second, try to compile code (run play application) and recheck routes files. I suggest that IDEA use compile routes classes to verify config.
Third, check syntax of your conf/routes . Are you sure want use -> ?

Intellij IDEA - JavaFX packager : access denied

I'm trying to generate an artifact of my JavaFX application using Intellij but for some reason I always end up having JavaFX packager throwing an access denied error on my output directory.
Generating a simple jar works fine though.
I'm using it on Windows 8.1 with Java 8.
I had the same problem. I kind of solved it:
by ticking the "Build on make" box in the Project Structur Dialog
starting a Run of my Java App in Intellij Idea
Now the executable jar magically appeared in my build folder. God knows why.
I had this problem and solved it by deleting the Artifact from IntellIJ, then deleting the "out/artifact" previously created folder where it tried to build my jar and finally re created an artifact from scratch. For no specific reason it now worked.
I have encountered the same problem recently. I checked the permissions of the directory and can read and write. Later I deleted the artifact and re-created a new one to solve the problem. I hope to help people who have encountered this problem.
I had this problem. I ran into it because When I added artifact with + button in Project Settings->Artifacts, I selected JAR artifact , and change JAR to JavaFx Application from type drop down box on right side pane. Later, I removed this artifact and pressed + button, then selected JavaFx Application from drop down list, then it was builded successfully. My JDK version is 8.
When I call JavaVXPacker from the command line I get the following:
C:\Users\Ingo>javafxpackager -help
javafxpackager.exe has been renamed javapackager.exe.
The original file may be removed in a future release in lieu of javapackager.
Please update your scripts.
...
...
So I guess IntelliJ has to update it's script to re-enable the feature???
(using Windows 10 and JDK Liberica 15+36)
Go to File > Project Structure
Click on Artifacts on the left panel.
Thereafter click on the plus icon to add a Jar From modules with dependencies…
A pop-up will be shown and there you would have to select for the startup class of your project.
Click on OK twice to save the changes.
Lastly go to Build > Build Artifacts... And select build action.
Now your jar will be generated in the out folder of your project.
For a more details guide, please refer to this post

IntelliJ IDEA Report Highlighting error when using routes in Controller

I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots):
I'm using IntelliJ IDEA 12.1.6 Ultimate version. Scala version 2.10.2
Anybody know how to fix this problem?
Thanks in advance!
Edit
When I generate my project to Intellij IDEA via "play idea" command in play console, and I opened project in IDEA project structure was such:
Then I saw answer #millhouse and discussing on this githup([Play 2.2] "play idea" creates not working source mapping in target) and I removed following folders from Sources Folders:
target\scala-2.10\src_managed\main\controllers
target\scala-2.10\src_managed\main\views
and "Report highlighting error" disappeared, but now there is another error:
and
my route:
And I've changed "Sources Folders" as shown below:
But it doesn't help me. And remains "Unspecified value parametrs" error.
millhouse's answer helped me find the right answer. Play 2.2 (and perhaps earlier versions, haven't checked) output a scala version of the routes file to project_dir/target/scala-2.10/src_managed/main So for IntelliJ to get the highlighting right you need to make sure that src_managed/main is added as a source folder. The reverse routes for javascript are for some reason included in project_dir/target/scala-2.10/classes_managed so you'll have to add that as well. (In your screenshot it looks like classes_managed is set to excluded so you'll want to un-exclude it by pressing the x button on the right hand side.)
Here's a screen shot of my project structure:
Update:
In Play 2.3 (or perhaps recent versions of IntelliJ) adding the classes_managed no longer fixes the problem. Instead of adding classes_managed to the project's sources add it to it's dependencies. By doing that IntelliJ should be able to pick up the compiled routes.class.
This is a common problem, it's because IntelliJ needs to be shown where to look for the compiled Scala templates and routes file. Here's how I fixed it on my IntelliJ 12.1 installation:
Go to the Module Settings for your project in IntelliJ (select the top-level, hit F4)
Choose the Modules item in the Project Structure window that appears
Select the projectname item (as opposed to the projectname-build item)
Add the compiler's output directory to the Source Folders items;
For Scala 2.10 it's target/scala-2.10/classes
I personally find the IntelliJ UI for this to be very non-intuitive; you might need to take the target directory and/or one of its subdirectories out of the Excluded Folders first
After applying that change, IntelliJ should see the results of compiling each routes and .scala.html file as just-another source file, so they won't show as "broken" and auto-complete should work for them.

Intellij prompting for path variables "USER_HOME_GRAILS" and "USER_HOME_GRIFFON "

When I start my project in Intellij 9 (#IU-95.66) I see a red popup in the top right of my screen saying...
Load error: undefined path variables!
USER_HOME_GRAILS, USER_HOME_GRIFFON
are undefined. Fix it.
I do not have the Griffon/Grails plugins enabled and never have, why would I get this?
The project was created with Groovy plug-in enabled and it has stored these variables in the project file. Either enable the plug-in or remove the variables from the project file.
Creating the new project should also help. We have a related issue in our tracker, you may join it and provide more information.
I enabled the Grails/Griffon plugin and can confirm that it solved this exact issue. I had reinstalled Intellij on another machine and this is one issue I had when starting up a project that was created under a previous install.
Thanks.!