I have a Gradle file which, whenever I load open it in IntelliJ IDEA 14.1.5, shows IDE errors for the entire file. Namely all the errors seem to be either:
java.lang.String errors
or
groovy.lang.Closure errors
I've tried clearing the file's contents and only writing the top line:
group 'com.me.blah'
but even that results in an error.
For context's sake - this is an individual module in a larger SpringBoot project. This module is a set of simple static files (with Gradle for CSS compilation, static analysis, etc), while the rest are Java modules, and are not having Gradle issues.
Can anyone think why IntelliJ would be struggling to understand this Gradle file?
I've noticed this often. When creating a new project and using the 'Gradle' template, IntelliJ seems to get it all wrong. So what I've resorted to doing is after creating a new project, delete the .idea and .iml files and re-open the project directly from the Gradle file. IntelliJ seems to better understand what is going on in this case.
For the first part of the question: group is a property, so there must be an assignment, not a function call. The right code is:
group = 'com.me.blah'
I found this suggestion in the IDEA bug tracker(IDEA-142683):
Workaround:
One can add a comment such as
//noinspection GroovyAssignabilityCheck
to suppress the warning, but this should not be necessary as these are standard every day Gradle usages.
This issue was recently updated and is marked fixed, ready for release with version 2016.2 release.
Try File | Invalidate Caches and restart. It worked for me after i mess the syntaxe somewhere else in the file.
For anyone looking for a similar fix, this boiled down to the type of the module. My module was defined in my .iml file as
type="WEB_MODULE"
I created a new Gradle module and pasted in the same contents, deleted the original, renamed the new module to have the same name as the old one, and everything worked fine. When I diffed the results the only change was that the .iml file now said:
type="JAVA_MODULE"
So there's the answer, seemingly. Change your module from "web" to "java".
For me, after trying out all this answers without result, changing the Java SDK of the project did the trick, I was on 1.8 and changed it to the newest one, but still a project level language of 8.
Hope this helps!
What I found is that this warning is from Groovy inspection of the Intelliji. So if your project is not pure groovy, you can disable this inspection by going to File -> settings -> Editor -> Inspections -> disable Groovy. Again, just a workaround.
Happened to me recently on windows. I tried all of the above but it didn't work.
What i did:
1 - I had JAVA_HOME environment variable already set. So IDEA picked that as project SDK and these warnings showed up.
2 - So, i removed the default JAVA_HOME from project SDK and manually added jdk path. Restarted and all warnings were gone.
Maybe it will help someone. Thanks.
Related
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.
I'm fairly new to using JavaFX and have been tinkering with it on my own in a few simple projects.
I have to collaborate with a few others for a main project, where I am seeing this conflicting issue:
I'm having an issue with the src.zip file of javafx. On my standalone projects, I do not encounter this issue. However, since working with others, this error has appeared. Prior to this, I was getting a Kotlin plugin issue, where I had to completely disable Kotlin.
Error:java: C:\Users\nolan\Javalibs\javafx-sdk-11.0.2\lib\src.zip
I'm unsure of what this issue might mean, so any help would be appreciated.
Thank you.
I had the same problem too and discovered it was because I added the JavaFX 11 SDK to Intellij incorrectly. I initially had the added library point to just the directory /lib. Since this directory includes both the jars and src.zip, Intellij will try to run both and produce the error.
To solve this, when Intellij prompts you to "Select Library Files," you need to explicitly select the files within the /lib directory which will then be added as shown here. This will also allow proper inspection of the source code without Intellij having to decompile the class file when ctrl + left clicking a class name.
Figured this out. I extracted the src.zip in the appropriate directory (deleting the zip as well), then had to change my VM Path to include:
--module-path "C:\yourpathto\javafx-sdk-11.0.2\lib;out\production" --add-modules=javafx.controls,javafx.fxml
I forgot to add ;out\production to the Module path.
A quick rebuild then solved this issue.
I know this question has been asked before and I have seen a plethora of solutions out there, yet none seem to work for me. I was able to build my apk without issues until this error started cropping up. I have tried cleaning my project, removing it from the workspace and reimporting it, removing "Java Builder" from my Builders for the project, building the project manually, reordering my java build path. I have no visible compiler issues and no problems exist in my workspace.
I did experience this issue before and solved it once by removing the project form my workspace and re-importing it and another time I solved it by removing "Java Builder" from my java build path. None seem to work this time. I currently have most of the settings set back to default (i.e. java build is checked again).
I am running windows 7 (64 bit) and using jdk1.6.0_21 via Eclipse 3.6.
Any suggestions would be greatly appreciated as I have lost loads of development time troubleshooting this already.
[Update] My locale is English & I have tried removing the debug.keystore, United States as related to issue 834
Please follow these steps; this might help you out:
Right-click your app project and go to Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
If your app project relies on library projects which are in your workspace, those of course need to have the "Is Library" box checked.
deleting the R.Java file in /Gen folder did the trick for me
I tried all the above solutions. but it didn't work.
The solution was to restart eclipse !!!!!!!
hope this will help someone :)
In my case this problem started after eclipse updated the plugin with the v4.0 API release. I fixed it by going to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Note: if you eclipse gives you the Unknown Command 'crunch' error then follow this post
I've tried to gather the best of other peoples answers into a step by step list of things to try in order:
Check the project is not set as a library:
Go to Project->Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
Clean and rebuild the project - this should delete and recreate the entire gen folder, including the R.java file mentioned in some peoples answers
Check eclipse and all the Android plugins are up to date
Close the project, exit Eclipse, reopen eclipse, reopen the project.
Go to Java Build Path > Projects and check for any incorrect project dependencies
Go to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Check JAVA_HOME is set correctly. Follow the steps in this article
If you complete the above list, and still haven't solved the issue, please leave a comment, or if you find something else that works, feel free to edit the answer and add your thing in.
Delete the project from your workspace & import again.
This worked for me.
Can't believe similar issue has been there since 2008.
http://code.google.com/p/android/issues/detail?id=834.
i'm no expert, but eclipse on Windows, doing android apps, refuses to create the default.properties file (in the app root directory). I've just copied one from another app and it works fine. Simple contents, for Android 2.2 project it just says (ignoring comments):
target=android-8
fwiw
I was having the same issue as the OP except that all these suggestions did not work. I found a solution for me.
Make sure that "Skip packaging and dexing until export or launch." is selected.
Go to Window -> Preferences -> Android -> Build. Just make sure that option is selected and apply.
I know this does not make a lot of sense, but having it unselected was giving me this error and with it selected it goes away and the apk is installed.
I am using the auto generated ant build script from android and ONLY using it as my build process in eclipse. I am not using any other build methods.
I figured it out. I was referencing JavaSE-1.5 and using JDK 1.6. I changed it to use 1.6 and that appears to fix it.
Seems like through my research that is an overloaded error message that covers a lot of error cases.
I just fixed this by reselecting a default JRE for the execution environment (JRE6 for JavaSE-1.6 in my case). It got unchecked for some reason.
This fixed my problem. I kept getting the console error in eclipse "Could not find com_android_vending_licensing.apk" and even though it didnt seem to effect the way my app ran, it was annoying. So going into the com_android_vending_licensing project properties and unchecking the "is library" option, building the project to produce the needed apk and then going back into the com_android_vending_licensing project properties and re checking the "is library" check box fixed the problem.
Run Eclipse as "Administrator" and then import the project.
None of these things worked for me. I'm trying to access native code through the jni, first with NDK samples. What I found was the build won't run if jarlist.cache is not present in the project bin directory. If I copy one from another project to that location (may need to refresh to see the folder in Eclipse), build works every time.
Clean the project and it will do. Sometimes it happens unknowingly but keep trying to solve using diff methods.
I had somehow done a Run configuration as a Java application instead of a Android.
the problem for me was I was trying to use IBM RAD which appears to not work properly for this, I installed Eclipse and now have a different error but I should be able to get past it
On my machine (Windows7, 64bit) I could fix this by setting my execution environment to a 32bit variant of the jdk (I used 1.6.0_23). And I tried a lot of things before...
SHA1's answer did it for me: after updating to the latest sdk/adt, my project refused to build an apk; unchecking the option resolved the issue.
I don't know if the update checked this, or if it was checked before but the new adt screwed things up, but things work again now :)
In my case this worked :
Delete R.Java file in /Gen folder
+
Delete all "R.Android" imports that Eclipse added to some of my java classes !!!
and rebuild the project.
remove -- R.java -- Clean the project and run again.. this worked for me ..
Find the project's folder in your system, enter it's Properties via context menu and deselect "Read only" option. Worked in my case.
This seems to be the source of the problem in many cases, moreover some solutions up there base on copying/rewriting the files in the project what makes them non-read-only.
This is caused by JAVA_HOME not being set correctly. It can be easily resolved by following the steps in this article.
Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:
Eclipse > Help
Install New Software
Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With'
section and press enter
After developer tools appears on the list, check it and click Next
Restart eclipse once download is finished
I my case, I had to switch from API 21 to API 19, clean and build and everything was fine again. I am using a Mac and apparently API 21 is not fully supported on Yosemite.
I get this error during compile-time of my GWT project, there is no such folder as 'gwt-UnitCache' to delete, as suggested in the following questions
Weird GWT compile error
exception in GWT RPC app
I'm using IntelliJ IDEA (IDE), SmartGWT EE (Framework), JBoss AS (Server) and JPA
Here's the error log:
If you change the value of your <module rename-to='<appname>'> in .gwt.xml it will give the same error :) but then you can just delete your gwt-unitCache and all is ok :)
IntelliJ IDEA stores GWT cache files in other location than <ProjectFolder>/gwt-unitCache, which is a default directory for a cache if you are using, for example, Eclipse with GPE (Google Plugin for Eclipse).
In IDEA, GWT cache should be located by default at <your_home>/.IntelliJIdea12/system/gwt (IntelliJ IDEA 12, Linux). For other operating systems you can check Project and IDE Settings.
If you delete mentioned gwt folder contents, IntelliJ will create a new cache, which in turn might solve your Failure in unit cache... (and similar Unable to read from byte cache) problem.
I had the same problem with Eclipse.
Unfortunately looks like the only solution is the one given by Crowlix.
I tried to delete gwtCache and Temp files, but nothing worked.
The problem only got fixed when deleting the entire project and re-importing it.
I was able to fix it by systematically removing, compiling and re-adding every artifact piece.
If you're having this problem, make sure you have a structure like this:
lib contains your compile-time libraries
I am face off this same error, this tip doesn't works for me, moreover, I keep about looking for a solution, and finally, I got this advice:
Java stack overflow error
I tried with -Xss1m, but the error persists, I keep on trying, my final value was -Xss5m
I am using GWT 2.5.1 and IntelliJ 12.
I've got same problem building a project with maven.
Usign both suggestion of Nishant and #iVieL:
$ export MAVEN_OPTS="-Xms512m -Xmx1024m -Xss32m"
$ mvn clean package
you must clean your project first (Project -> Clean)
then remove /gwt-unitCache
then rebuild it.
So I have a maven module (module-A) in IntelliJ. I recently moved some classes from it into another new maven module (module-B) and added a dependency to it. Once I had done this I also modified the signature of a method of one of the moved classes (now in module-B).
I re-imported the poms so that IntelliJ would pick up the dependency changes and ensured all Java imports for the affected files were correct again. Now when I attempt to run my webapp (which depends on the two modules) I get a compile error in a class in module-A calling the modified method of the class in module-B.
The error message is basically saying that that method doesn't exist but believes the old method still exists! I click on the 'make' error and it takes me to the line in a class in module-A calling the modified method...the weird thing is, IntelliJ knows it is fine in the file. i.e. The method is not underlined in red like a compile error would normally be, but the class file name is :(
I compiled it from the command line using 'mvn install' (having also installed module-B) and it is all successful. I have deleted the classes directory in the target of both module-A and module-B and also invalidated IntelliJ's caches and restarted...still happening...any ideas?
I found out that this might help:
File -> Invalidate Caches
Maven Projects -> Reimport should help.
I spent a few hours on this same issue. All of the cleans in the world didn't help.
I deleted my out and target directory in my project and recompiled - that cleared it.
Edit: There is also a magic feature under the file menu: "Invalidate Caches / Restart" This fixes a bunch of "intellij is confused" problems.
Change "Java Compiler" setting in IDEA (User compiler javac in-process) to fix the problem.
Try to mvn clean your projects and mvn install your project B.
The maven integration with intelliJ is kind of buggy when you use the make command directly provided by Intellij. You should directly use the mvn commands, or start them from the maven panel.
I ran across a very similar problem that was driving me insane.
My code would compile fine with the ant task I normally run, but it would not build in IntelliJ, complaining about "Cannot Find Symbol blah blah"
Turns out, you can add "Excluded" files for the compiler. My file somehow got added to that list.
This list is located in File > Settings > Compiler > Excludes (IntelliJ 13)
Following steps should fix this problem :
delete .IntelliJIdea12 / .IdeaIC12 older under c:/user/.../
Invalidate Intelli's cache: File > Invalidate Caches.
This re-indexes your workspace on start-up and also clears your local history. Before you do this, commit or back up all your uncommitted changes.
Once your workspace is back after indexing, do a maven clean install.
when the build is successful, click on Maven Re-imports
This worked for me, I think it should work for others too with a similar problem.
So just stated it up this morning and it's all working!
Last night what I did do was open a new project (intelliJ project) from module-A's and module-B's parent pom and successfully got it to build, possibly doing that and then opening my original project again fixed it somehow...very annoying though
The behavior I see is similar to the one described by the original author.
Error markers show up on the right side of the editor in Intellij 14 and less so in 13.
This happens also if using Scala instead of Java and using SBT instead of Maven.
Also noticed this occurs after the second project is loaded. The first is always fine.
(After much trial and error) Figured it might be caused by Intellij's internal caches becoming somehow corrupt. "Invalidate caches" worked sometime and sometimes did not.
I work with a number of projects using Play! Framework and they use different versions of Scala and lots of dependencies.
I hypothesized the caches become corrupt because the internal key Intellij uses is not good enough to handle situations when the same class, loaded multiple times in different jars, has different signatures, and this results in the editor errors while external builds work fine.
Then the "Changing Ivy Cache Location for sbt projects in IntelliJ IDEA?" post gave the idea to segregate the ivy cache SBT and Intellij use in the hope that the ivy path is part of the internal cache key.
Paul Phillips of TypeSafe provide the "SBT extras" tooling and here I found a way to instruct SBT to use a project based ivy home, cache and SBT boot:
https: //raw.githubusercontent.com/paulp/sbt-extras/master/sbt
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
How to configure Intellij
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/ec8ec491-6d0c-4691-9598-916a63ba65ef/12.02.2014-08.59.png
Then did the same for the external SBT build to work in sync
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/dcb287c4-200f-47f3-a937-42865675a22b/12.02.2014-09.01.png
Finally got rid of the user home based .ivy2 and all the contents.
To be sure Intellij does not use this folder I made it readonly.
This was a mistake. Intellij seems to silently fail resolve dependencies if you do this.
This solved the errors and believe they will not come back. :-)
If Intellij guys hear this: please test your releases (Scala, SBT, editor) with all the Play Framework templates from TypeSafe. The problem becomes apparent quickly this way.
I just had a similar issue that was driving me insane. I had done all the other things mentioned in the answers above because I have used Intellij forever, but none worked. In the end I found out that in the maven projects portion of Intellij, one of my modules had been marked "ignore" a simple unignore command from the context menu did the trick.
In my case, I had manually marked a directory as "Test Sources Root" but IDEA marked it on a parent Maven project. Unmarking it in File->Project structure...->Modules fixed the problem.
This could happen if you are using different version of java while building outside IntelljJ. My IntelliJ had java10 and I was using java8 while building at terminal. Changing java version to IntelliJ fixed this issue for me.
I had a very similar behavior. Running (Scala-)tests would always fail due to errors in unrelated java classes during the 'make' step.
It turned out, I had included a 'global' SDK library that collided with one of the dependencies from the project. A proper helpful error message only showed up after I deleted the 'make' step from the test.
I then deleted the duplicate library, re-added the make step to the test and everything is now working fine.
I ran into this problem today after upgrading from 12 to 13.
Later I fixed issue as I used the same name for Project and Module and looks Intellij allows this but cannot handle it correctly.
No idea why setting will impact the compilation, although there is no error in java editor. Should be a bug in version 13.
I was facing a similar issue after upgrading from IntelliJ 12 to 13. After multiple uninstalls and re-installs (of multiple intelliJ versions), numerous cleans and .m2 repository clearing, I finally figured out what my issue was.
In my intelliJ settings, the repositories mentioned in my main POM file could not be connected to. this was in turn due and alternate repository that was mentioned as a part of my pom file.
Once the POM was made to point to the correct repository, all my classes had their compilation issues resolved.
To check if your repositories are being connected to, go to File -> Settings -> Maven -> Repositories
Here, your indexed maven repositories should be connected to successfully. If they are not, then intelliJ will not be able to resolve most 3rd party and module dependencies.
I'm embarrassed to say, but we also had this problem, but it was due to a mistake in our package name.
When creating the packages for a new project I accidentally created a package called "org.package".
My project then had a directory structure like:
/src/main/java/org.package/
Which caused all sorts of havoc with IntilliJ.
Once the correct folder structure was created on the file system, IntelliJ worked great.
/src/main/java/org/package/
Note the difference in /org.package/ vs /org/package/
The fix was i made it javac instead of Ajc and i put 1.8 of course according to your jdk version.
for some reason when i invalidate and restart intellij it was set to be the default !
my version is
This happened to me...what fixed it was realising there was an extra main.iml file in the source directory. Deleting that instantly made the compile errors go away.
None of the above answers worked for me.
In my case, I had to finally create an explicit Maven Run Configuration for the module (with Command Line as "clean install") and then run it.
It is in Run > Edit Configurations
close the project
go-to the project folder and delete idea project file and .iws file
run mvn idea:idea
restart the project.
seems idea keeping the old project dependencies without cleaning even though we run file -> invalidate caches
Setting the proper Java SDK solves the issue
Right click on the project and select "Open Module Settings"
Check if you have the right Java SDK under platform settings
Check the SDK under Modules
Rebuild the project from "Build" menu
Delete the installation directory.
Remove the following directories:
~/.config/JetBrains/
~/.cache/JetBrains/
~/.local/share/JetBrains/
This will remove each and every configuration plus installation of jetbrains tools, be it IDEA, goland,etc.
Now install everything from scratch.
That's the only way it worked for me