Related
I have a maven java project that I would like to use IntelliJ for development on. One of my favorite navigation features of IntelliJ is the 'go to > implementation' feature that appears when you right click on a method or function.
My problem is that this feature is not working for me; when I choose it nothing happens, no error, it just sits right where it is. It also isn't suggesting functions and methods as I type, so it's as if IntelliJ is failing to recognize dependencies and relationships among the various classes in my project.
I know the code is fine because it compiles and runs, has anyone else experienced this? I made sure to open the project as a maven project using the pom.xml file but that made no difference.
Right click on the root folder of your project (Application code folder)
and
select -> Mark Directory as -> Sources root
It seems that the index is wrong.You need to force reindex the project files.
Just try:
File -> Invalidate caches...
Then restart your IntelliJ
This is way too broad of a inquiry!
There's a few things that could be wrong but compiling and running has nothing to do with it. Compilers such as maven can generate sources or modify behaviors of compilation units and can be considered non-deterministic programming which because of its very essence, can't be analyzed.
You're referring to a Contextual IntelliSense operation; in the context you're in currently, dependencies etc may not be properly configured. You can't know what you don't know; similarly, Intellij can't either. Make sure all libraries are listed properly within the Project/Global -> Libraries section in order to have them properly function.
Alternatively, your cache could have become corrupted. Try File -> Invalidate Caches / Restart...
Lastly you could simply have the option disabled somehow. There's various settings which will disable the option. For example, Power Save Mode may be enabled. For the rest I suppose it'd be best to refer you to the help documentation.
I had the same issue with idea and i did:
"Mark Directory As > Sources Root" not worked.
"Invalidating cache and restart not worked"
"Deleting .idea and .iml files not worked"
Finally right click on pom.xml and select "add as maven project" worked for me.
Ishnark's comment on my question provided the solution I needed, reposting here so that it can be upvoted and hopefully help others. All I needed to do was right click on the source root of the projecet and select "Mark Directory As > Sources Root". More details here:
solution
In my case the problem was the next: for some reasons *.py files were registered as a text files, not python ones. After I changed it, code completion started to work again.
To change file type go Preferences -> Editor -> File types -> add *.py into Python again.
comment from: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005050480-Cannot-find-declaration-to-go-to-solved-
GO TO File>New>Project From Existing Source then choose you're project
let maven build you're project again.
Intellij doesn't show run button even if that file is in src folder.
Maybe do you know what to do?
P. s. It's strange because that file used to show run button but after recloning git repository it just doesn't show any more.
Right click on src directory and select option Mark Directory As > Sources Root.
There is an Intellij bug that will result to an intermittent disappearance of that little tiny green run button on the left side of the source code (on same column where the red circle breakpoints are). Yes, you can right-click on the mouse and can do the run via the menu, BUT we love that tiny green button so bring it back!! From time to time, i see this green friend and then suddenly it vanish mysteriously and comes back again. I did all, such as rm -rf .idea and other weird stuff, but no explanation has ever been achieved to explain the vanishing green button and it's sudden re-appearance intermittently.
I am drafting this answer, because all of the above answers seems to claim that there is a logical explanation of the intermittent disappearance of our little green friend and that a sequence of steps exists to make our little green friend re-appear, when in fact, there is no such steps and we just have to accept this is a bug to save the remaining hairs in our scalp.
In my case Run/Debug buttons disappeared for all projects after updating from IDEA 2019.2 to 2019.3. Tried checking Sources Root, Invalidate Caches, Run/Debug configurations etc - no luck. Only restoring Run/Debug action group helped:
Right click on main toolbar (where the button disappeared) > Customize Menus and Toolbars... > select Run/Debug > Restore Run/Debug.
I got the same problem with intellij 2019.3 and 2020.1 and found the solution here : https://youtrack.jetbrains.com/issue/IDEA-228180.
Basically, in the IDE the buttons run/debug and the error detection in the code were missing.
The fix was to disable the plugin 'Gradle' (I don't need it anyway) :
Settings > Plugins > Gradle and click disable and apply.
After restarting your IDE it should work
I had this issue when building a microservice with SpringBoot.
I added a new microservice into the root folder and I could not run it.I am using Maven.
Step:
Open pom.xml
right click and select "Add as maven project"
It should resolve it immediately but you can reload the IDE if it does not update immediately.
IDE: Idea 2021.2.3
Build tool: Gradle
I removed the .idea and reimported the project from the Gradle source. Worked fine after.
Another reason could be the Highlighting Level set to None, it should be set at least to Syntax.
First, make the folder as source root.
Second, make sure you set the project’s sdk correctly. For example, if you set the sdk correctly then import java.util.Scanner can be analyzed by IDEA.
Tip:
try not setting the SDK to IDEA’s bundled JDK. I set the project’s SDK to JDK 11 bundled by IDEA at first then found it couldn’t resolve import java.util.Scanner. Setting to JDK 16 which is installed by the OS’s package manager solved this problem, then the “run” button showed up.
If IDEA can index a java file then the file icon will show with a small “c”, indicating a java class. If not, the file icon will show with a small “j”, as this problem’s image shows, indicating a java file which IDEA doesn’t index.
In my case there was a plugin (springboot helper) which I had to disable.
Reinstall the IDE, it solved my problem.
I also applied all these methods but it still didn't work so I stopped my window firewall and allowed access for this application. I don't know how it worked out for me but it just got displayed on top of my screen that window defender firewall has stopped some of this app's features and there was an option to allow so I clicked on it and it now works just fine.
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.
Yesterday I refactored my project and I changed layout of my packages (I moved some packages into another packages, created new packages etc). But now, when I try to run JUnit test I get NoSuchMethodError on methods which name is changed after refactoring. Also, when I change other code in methods, IDEA still running old code.. I tried to run "Invalidate caches" in File menu, also I tried to reboot computer - no result. Where can be problem?
EDIT: Yesterday after moving packages IDEA doesn't correctly change package declarations in .java files, so I changed them by hand
VCS -> Refresh File Status solved this for me, when Intellij suddenly stopped noticing changes.
What I did in order to solve the issue was to "invalidate and Restart":
File -> invalidate and Restart
SOLUTION:
Error magically gone after 2 things:
I imported this project into eclipse and run JUNit test from eclipse. Then I returned to IDEA and deleted all Eclipse specific files.
I synchronized my project (File->Synchronize).
I don't know what actually was the solution of problem, but for suggestions I accept #SeanLandsman's answer
I have two suggestions you could try here
Edit your test configuration(s) and ensure that they're pointing to what you expect them to. I've sometimes seen a refactoring not being picked up in the run configuration and I've had to manually change it
Less likely to work, but try to synchronize your project: File->Synchronize. Do this at the highest level of your project
With regards to your edit - I've not seen this myself. Whenever I've renamed or moved files (including packages) these changes have been correctly applied to all applicable files. Are you refactoring with Refactor>Move / Refactor->Copy ?
Answer to an old question, but:
If you're using a Run Configuration, make sure in the "Before Launch" section of the "Run/Debug Configurations" dialog, you have added "Build". It seems to get removed from this dialog sometimes, even if you have it added in the default settings.
Deleting the entire content of the classes dir worked for me
Another root-cause can be:
If you are using Lombok, try to deinstall/reinstall the Intellij Lombok Plugin.
That solved such a strange behaviour in my case!
Try deleting .class file of class where nosuchmethod error is throwing, and recompile.
This worked for me.
In IntelliJ IDEA,
Right click on the project.
Select Git -> Show History.
Opens "Version Control"
Then you can navigate to Local Changes Tab.
Found this posting from IntelliJ and Maven not finding POM changes. Had to Reload All Maven projects to fix it. Maven panel, upper left corner circle of arrows button.
For some reason Eclipse is no longer showing me Java compilation Errors in the Problems View.
It is still showing Warnings.
This has suddenly happened and I cannot think of anything that I have changed which would affect this.
I am using the "Maven Integration for Eclipse" plugin but I have been for some time - not sure if this could have affected it or not.
Any ideas?
I had same problem and randomly did such things as (several times):
1) Project->Clean...,
2) close and open Eclipse again,
3) Run As...
And it started to work again, without changing configuration.
Right-click your project and go to Properties > Java Build Path > Source.
Make sure your source directory (for example MyProject/src) is listed as a Source folder. Otherwise you won't get any red markers.
I want to post my story here if Google brings you to this question.
Somehow, "Project->Build Automatically" got turned off.
Turning it back on produces correct errors list.
In my case it has nothing to do with m2e 1.0. This is default behavior for any Java project and goes back as far as Ganymede ( at the point of writing this post I am running Indigo )
This is not totally an answer to your question, but is related. I thought eclipse stopped showing red/yellow flags next to files in my project. The solution was very simple - I was looking at the Navigator tab (which doesn't show error/warning flags) instead of the Package Explorer tab.
I installed and deinstalled ajdt-plugin and got the same problem.
Check <Project><Properties><Builders>.
It should have a 'Java Builder'.
This code should be in the .project file (file is in the root of your project):
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Check your source directory is listed in source folder of project
Right-click your project > Build Path > Configure Build Path > Source.
If you are using multiple projects (as dependencies)
Project->Clean...,
Check "Build Automatically" is enabled or not.
project > Build Automatically
What worked for me is creating a New Problems View (this option is accessible from the three-dots View options):
The new View does show all the warnings and errors that were detected:
I was experiencing this problem as well today. The other solutions presented here (such as cleaning the project and restarting Eclipse) did not work or were not applicable to my setup. What did work for me was right-clicking on the project in the Package Explorer and selecting Maven->Update Project Configuration. Evidently some source folder restructuring I had done the previous day had caused Maven to lose track of things, and issuing this command fixed everything.
At the top right corner of the problems window (next to minimize) there is a small arrow-icon. Click it and select "Configure filters". There is a severity filter that might have been activated.
I have the same problem in slight different situation. I have a parent POM and multiple modules under it. Project was existing and I imported it into eclipse. I can change the "Dependency management" only to parent project but not projects under it. They are not showing any compilation warnings.
Next I'm going to try to change them all into individual projects... that's not what I wanted, but I haven't been able to solve this otherwise...
I have also faced the same problem.
After installing m2eclipse plugin, i was not getting any Java compilation errors.
My solution was to enable dependency management by Select Project -> Right Click (to get context menu) -> m2 Maven -> Enable dependency management.
Now i am able to view Java Compilation Errors.
This is normal problem. In wich order and export function sometimes get turned off.
right click on project<properties< there u hav option
build path < and there ORDER AND EXPORT< click right all the options....all the things are right back.
On Ganymede, check the configuration of the Problem view:
('Configure content') It can be set on 'any element in the same project' and you might currently select an element from the project.
Or it might be set on a working set, and this working set has been modified
Make sure that 'Match any configuration' is selected.
In my case Eclipse wasn't properly picking up a Java project that a current project was dependent on.
You can go to Project > BuildPath > Configure BuildPath and then delete and re-add the project.
There are obviously several reasons why this might occur, and I thought I'd add the solution to my issue. (I have a java project into which I have imported files with virtual links)
If you have a situation like mine, you will have another folder on the same level as your 'src' folder. If you do, right-click on that other folder, then select 'Build Path' > 'Add to Build Path' (if you see 'Build Path' > 'Remove from Build Path', then it had already been added.)
To further configure the Build Path, right click on your top level project dir, and select 'Build Path' > 'Configure Build Path'. Your folders should show up in the 'Source' tab.
To configure what errors you see, Click on Java Compiler > Errors/Warnings and then click 'Configure Workspace Settings'. That is the same as going to Window > Preferences > Java > Compiler > Errors/Warnings. If you don't want Eclipse to ignore something, then just change it to Warning.
Try following:
Open Problems window (Windows -> Show View -> Problems)
Right click on the error and then Quick Fix
This procedure helped me solve the same problem.
If you have reached here that means all the other solutions did not work for you.
One reason could be your source folder is not a java project.
Solution would be to run below command on the source folder
mvn eclipse:eclipse
This worked for me.
If this also doesn't work then try removing .classpath and .project file and run the above command again
I could reproduce this issue by creating an enumeration with a non-static member class and a static block enumerating its values:
public enum Foo {
Dummy(new Bar [] {new Bar()});
static {
for (Foo foo: Foo.values());
}
private Foo(Bar [] params) {}
public class Bar {}
}
This class breaks the Ganymede compiler. If you delete the line in the static initializer block, the code compiles correctly again, and you get the error that there is no enclosing instance for the new Bar() call, as expected.
-- correction: The above holds only if the project has gaeNature from Google Appengine. However, if you get an error similar as mentioned in the original question, you might be encountering another java compiler bug ...
I have the same issue with Eclipse Helios and the m2eclipse plugin. They just can't seem to get this thing to work with WTP or WPT or whatever the blasted acronym is.
If I do a clean on the project and watch the Maven console then I can see the compilation issues in the console but eclipse won't touch it. It seems eclipse or WTP/WPT and m2eclipse are busy playing slap hands.
I experienced that problem with a MapReduce project. I closed the error window and never came back after doing what the other answers suggested.
Click on the bottom left -> Other -> Problems
Kepler SP2, Java Project (Web Driver), and we use Gradle instead of Maven
None of the above helped, what did fix the problem for me was to select my projects (r-Click) > Gradle > Refresh All
Pointing the source(src) folder to the build path will solve this easily
to do so
right click on the project > build path > configure build path > java build path > source > add folder and click Apply
My mistake was that I was creating classes in resource package...
Creating classes in src/main/java solved the issue.
Check your filters, sometimes problem view could be scoped to a working set that you are not currently working in. Also, you can check other configurations for the problem view.
Problem in .classpath
I did "Replace with HEAD revision" to get back the version that I had in the repository Git and the errors appear again.
Duplicates in build path
In my case, errors were not showing up in the Problems View or Package Explorer views because my build path had duplicate entries for src and test directories:
Removing these from Project -> Properties -> Build Path (and just leaving one each) did the trick.
In my case I setted a old workspace and it was the problem.
Try to set a new folder for workspace
If "Debug" has been recently activated then check the top right of the program (under the Minimise button) and click back onto Java.