Intellij IDEA doesn't detect changes - java

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.

Related

What does the yellow background on filename mean in Intellij?

I think it might have something to do with asynchronous tasks but I don't know for sure. Could someone please clarify this for me?
Also what do the yellow frames mean when you are debugging?
If this suddenly happens to your project:
Consider closing pycharm and deleting the .idea/ folder of that project.
After reopening the project the project, pycharm will detect all files as normal.
But you'll need to set up the project again.
-> Set source-folder, add run configuration etc.
For me that was the faster solution than figuring out how to fix it.
One more mention: It happened after a merge which caused some version conflicts and required to "roll back" a file.
This also happened to me and the cause was that the project folder was removed from the 'project structure'. You can re-add it in Settings-> Project <...> -> Project Structure.
See also the documentation: https://www.jetbrains.com/help/pycharm/configuring-project-structure.html
The above solution did not work for me -- by happenstance, I was clicking around the settings in Intellij/GoLand and stumbled across a solution that worked for me.
When I went to the Project Structure, the Project Structure pane was empty and there was no way for me to manually re-add my project directory.
Fix that worked for me:
Top Menu Bars -> File -> Repair IDE
A bubble window shows up on the bottom right, and I just clicked through the tooltips to repair different aspects of Intellij. In my case, the 'Reindex Project Structure" step worked for me (it was Step 3 of 6 in the repair process).
After repairing + waiting a bit for the project to reindex, everything went back to normal.
This color indicates the non-project files (libraries), you can customize it here:
Make sure to restart the debugger for the changes to have effect.
As #Framester points out, the project source is missing from the IDE config.
Right clicking on project root you can add that as a Source
Select:
Mark Directory As -> Sources Root

IntelliJ IDEA and Gradle - Cannot be applied to '(groovy.lang.Closure)'

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.

Java Error when i press button [duplicate]

This error is just bizarre, my code compiles fine, I can see there are no problems with it, yet this error has just popped up. I have tried re-starting NetBeans and there is no additional exception information.
What can cause this?
If it is Netbeans, try to uncheck "Compile on save" setting in the project properties (Build -> Compiling). This is the only thing which helped me in a similar situation.
I guess you are using an IDE (like Netbeans) which allows you to run the code even if certain classes are not compilable. During the application's runtime, if you access this class it would lead to this exception.
It's caused by NetBeans retaining some of the old source and/or compiled code in its cache and not noticing that e.g. some of the code's dependencies (i.e. referenced packages) have changed, and that a proper refresh/recompile of the file would be in order.
The solution is to force that refresh by either:
a) locating & editing the offending source file to force its recompilation (e.g. add a dummy line, save, remove it, save again),
b) doing a clean build (sometimes will work, sometimes won't),
c) disabling "Compile on save" (not recommended, since it can make using the IDE a royal PITA), or
d) simply remove NetBeans cache by hand, forcing the recompilation.
As to how to remove the cache:
If you're using an old version of NetBeans:
delete everything related to your project in .netbeans/6.9/var/cache/index/ (replace 6.9 with your version).
If you're using a newer one:
delete everything related to your project in AppData/Local/NetBeans/Cache/8.1/index/ (replace 8.1 with your version).
The paths may vary a little e.g. on different platforms, but the idea is still the same.
I also got the same error and I did clean build and it worked.
Add selenium-server-standalone-3.4.0.jar. It works to me.
Download Link
Recheck the package declarations in all your classes!
This behaviour has been observed in NetBeans, when the package declaration in one of the classes of the package refers to a non-existent or wrong package. NetBeans normally detects and highlights this error but has been known to fail and misleadingly report the package as free of errors when this is not the case.
I had the same issue with one of my netbeans project.
Check whether you have correctly put the package name on all the classes. I got the same error message because i forgot to put the package name of a certain class (which was copied from another project).
Disable Deploy on Save in the Project's Properties/Run screen. That's what worked for me finally. Why the hell NetBeans screws this up is beyond me.
Note: I was able to compile the file it was complaining about using right-click in NetBeans. Apparently it wasn't really compiling it when I used Build & Compile since that gave no errors at all. But then after that, the errors just moved to another java class file. I couldn't compile then since it was grayed out. I also tried deleting the build and dist directories in my NetBeans project files but that didn't help either.
Organize your code as a maven module.
Once done run the command from terminal
$mvn installl
to check if your code builds fine.
Finally import the project in netbeans or eclipse as maven project.
change the package of classes, your files are probably in the wrong package, happened to me when I copied the code from a friend, it was the default package and mine was another, hence the netbeans could not compile because of it.
I had this problem with NetBeans 8.0.1. Messages about problem in project deleted class. Deleting the ~/.netbeans didn't work. Also I looked for ANY reference to the deleted class in ALL my projects, nothing found. I deleted the build classes, everything. Then, when I started Netbeans again, compile and magically appears the message in Run and into the mother compiled class. I tried the uncheck "Compile on save" Dime solution, and works, but it's not practical.
Finally, my solution was edit and force recompile of the mother class. This way the new .class doesn't contains the message and Run works OK.
Just check the packaging, the simplest answer I can provide is that your package has been mislabeled (within a class).
Also, you may have some weird characters. Try white-flushing the code in a Notepad (or Gedit) and then pasting it into a newly created class with your IDE.
If you are using Netbeans, try to hit the Clean and Build button, let it do the thing and try again. Worked for me!
I had the same problem. My error was the packaging. So I would suggest you first check the package name and if the class is in the correct package.
Implementing my own functional interfaces resolved this for me (so instead of using java.util.function.* just create your own single-method interface with the parameters and return-type you want).

PhoneGap Android "Could not find *.apk" [duplicate]

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.

Running unit tests right click context item not visible with IntelliJ 12

I downloaded the latest intellij 12 release, and now I don't see that right click context menu item to run my unit test for the current file.
Where is that option now?
Just had the same issue in a maven project - I had forgotten to mark the test class as public which resolved it immediately.
The solution which worked for me, is as follows...
Right click on the test folder------>Mark Directory AS------>select Test Source
I also had this problem under IDEA 14.1.4 but JUnit plugin was on.
After some time spent on comparing my old {HOME}/.IdeaIC14 folder and newly created one, I've discovered that problem lies in AntDebugger v1.2.0 plugin. Uninstalling it helped.
So if anyone still have problems with run item in context menu maybe it's because of some underdeveloped plugin.
Try to add junit plugin.
Preferences -> plugins -> junit.
For some reason my project settings seemed to have not been picked up correctly with IntelliJ 12, I had to reset the /test folder as a test source and it works fine now.
Test sources were marked correctly in my case.
File -> Invalidate Caches -> Restart did it for me.
What solved it for me was to put the test files inside a separate directory. Moreover, the test directory should be located OUTSIDE the src directory. Then, I had the right click menu item to mark the directory as test. Finally, I had to make both the test method and class containing it 'public' and also the method had to be 'public void'.
I have no idea where are all these restrictions documented. I am new to Java and JUnit, anyway.
In my case, the issue occurred because of the Node plugin; disabling it fixed the issue; after a restart of IntelliJ, my Run options were back.
I could identify the issue by looking at IntelliJ's logs, where there were NoSuchMethod errors when I right clicked on a test class/method name.
I reinstalled IntelliJ on mac and it worked again.
I had this issue in IDEA 14.1.4. Somehow, my JUnit plugin became disabled in Settings --> Plugins. I re-enabled it and am back in business.
That means IntelliJ was not able to configure your workspace as python workspace. It generally shows a message when it detects python scripts and provide an auto configure option like "configure python". This message was not appearing when I was opening python workspace and hence no tests were getting identified.
I faced this issue when working simultaneously between Java and Python unit tests. The caching might have prevented identification of unit tests in python workspace.
I just restarted cache using the option available in File menu (IntelliJ IDEA) and it reconfigured python as soon as I opened my python workspace after cache restarted.

Categories