IntelliJ suddenly "forgets" SDK and Module when opening any project - java

All of the sudden with no warning, any project I open in IntelliJ opens the .iml file only. If I go into Project Structure and set the .iml file to the root for the module, I can get the project view back, but then it says the SDK isn’t defined. If I do that, it works again but I have to reopen each folder under src folder (my java classes) individually, and when I exit and come back in I have to do it all over again.
This is happening for every single project I try to open, and I haven’t messed with any settings to cause this. Do you know what I can do to fix it? I am having to redefine the root module and sdk every time I open a project rather than it using the defaults as they are set, so each time I open my project I have to define it all over again because it has “forgotten” the module and SDK. I saw a fix that said to back up and delete the .idea folder but it didn’t help anything so I’ve added it back.
As of now, any project I open, new or old, has no defined module or sdk, even though just yesterday any project would open without a problem.
EDIT: If it helps I also use Pycharm, which is also by JetBrains, and I am having no trouble with it.

Wow Yes, "one drive for business " causes this behavior oddly.
Fix:
Moving the entire folder to outside of one drive has
fixed it,
after 2.5 hours of experiments by two of us!
-Henry

I disabled the "files on demand" feature in One Drive and that worked.

Related

Sudden weird errors on a project

Today I came to work, happy. But when I opened my Eclipse, I saw that one of my projects has errors.It's weird because it shows that it has errors only in the window bar, and not in the Navigator. I don't have any Java errors, this is a valid project that was fine all the time:
Some of the errors on the error log of Eclipse:
JavaBuilder handling ImageBuilderInternalException while building: SP_Procedure
Cannot connect to VM
File <SomeFile> has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Internal error
When I run an application from this project, I get a warning message but when I proceed, it works fine, but still. It's very disturbing and I'm not sure if it's harmless.
I tried to:
Restart Eclipse
Restart my machine
Clean projects and recompiling them.
Refresh projects
Pray
Nothing helped. What could be the problem? (I'm using Indigo Service Release 2)
The following nuclear option has desperation written all over it. But I have been where the OP has been with the Juno version of Eclipse.
Run a "Synchronize with Repository" and save all of your local updates to a different directory.
Delete the project. (Check the box to delete the contents on disk. Scary step, but that's OK, because you saved it in a different directory in the previous step, right?)
Read in a fresh project from the repository. It builds happily at this point.
Integrate your local updates.
Keep on praying.
Looks that one unused JAR was deleted, but for some reason, I didn't get errors in any file, even in the files that imports this JAR! So what I did was restoring this JAR, delete unused imports and deleted the JAR again.
I've found this error after two days of navigating on this project on each file.. This is weird that Eclipse didn't recognize that1 this is an error, and throw many unrelated errors such as:
Cannot connect to VM
File has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Is this a bug in Eclipse? (All errors and warnings are enabled!)
1 As seen in the image in the question..
A class from the list of imports for the file seems to have moved out or the jar file containing the class is missing.
Expand the imports section and check if you find some classes that are missing but have been imported.
Though it is a pain, sometimes the easiest solution is to back up all your projects (either in a repository or somewhere else on your computer) then uninstall and reinstall eclipse. No it's not fun, but it should reset eclipse so everything works again. The downfall though is that you have to reconfigure eclipse to any special settings you had/reinatall any extra functionality currently installed (eg. android add-on) and reconnect to any repositories you have. While punting isn't fun, it can be effective... I hope you don't have to resort to this though.
I have went through that problem a lot of times, and tried everything you tried. Rebuild, recompile, refresh, remove and add JDK, remove and reinstall Eclipse... nothing worked
The only thing I concluded is that the workspace metadata was corrupted.
What I did (every time it happened) was
Create an empty workspace
Import -> existing projects into worskpace
Mark the "copy projects" (else it will only link them)
Wait for the copy, and start working with the new workspace
If you work with SCM systems (Git, SVN, etc), making a full checkout will do the trick too, but the worskpace import will let you retrieve those changes you didn't get to commit (if any).
It's a little painful if you have somethings already set (like JDK names, servers, etc), but then I realized it was faster than keep searching how to fix the workspace
Regards!
PS : I've been working with Kepler lately, and everything works fine till now
Click Window -> Show View -> Other -> General -> Problems
This view will show you what is wrong.
Did you, by any chance, update your virtual machine outside of Eclipse? I can't help but feel that we're both missing a finer detail here. I just keep seeing "cannot connect to VM" and thinking that it's a major clue.
Have you tried running anything from the terminal? Does it work there?
If so, do you know where your current edition of Java is located? Is Eclipse looking somewhere else?
Is this exclusive to one project? Do you use any additional libraries to the JDK?
Maybe try this for Resource is out of sync with the file system error:
Right click project in Eclipse Package Explorer
Close Project.
Right click project in Eclipse Package Explorer
Open Project.
Other things not mentioned:
project properties > java build path, see if any of those tabs got changed, local file got moved? read/write permissions on some file you are linking to?
project properties > java compiler, see if workplace settings have changed? maybe under errors/warnings, you can systematically set them to 'ignore' until the error goes away to determine what type of error it is?
maybe update some of the eclipse plugins?
I saw something like this happening for a number of reasons. Mainly because of validation in files other Java source code. See if you are validating XML for instance.
Right click your project and chose Properties (Alt+Enter) and Validation to see the related configuration.
As for the danger, I lived with those marks for ages and nothing wrong ever happened.

IntelliJ IDEA 12 duplicate class R.java and BuildConfig.java

I use Eclipse for android development and trying to use IntelliJ. I have successfully run the application once. But now, I couldn't seem to rebuild the example Hello World application. What am I missing here? The R.java is not rebuilding anymore. Here is a screenshot of the errors.
And here is my setting
This happened to me because I've marked source folders incorrectly.
Under project settings once you click on particular module, Just check whether you have Mark any additional folders as source folders.
Check the screenshot, By default it should be something like below, All mark as buttons should be unchecked
By mistake I've checked Mark as: "Source" button and I got this error. Just uncheck it.
R and BuildConfig are autogenerated by the android build system. Maybe you somehow copied an autogenerated version of your eclipse project into the idea project and then idea generated second ones. By default, idea will use a folder called gen for these files which is marked as a source folder. Make sure there are no other source folder containings these files.
You can quickly find classes by pressing Ctrl+N and starting to type the name of the class. If you find duplicate results, delete any of them and let idea regenerate the correct ones.
Unfortunately you may not like my answer, but my project is due yesterday and I don't have time to check every setting to fix the issue.
The way I resolved it is to re-create a new project, only copying the src, res, lib etc across. This was painfully difficult and presents other issues (manifest files and run/debug configs) , but proved relatively short as opposed to creating a new project ANYWAY and sifting through build options that may or may not be valid.
I encountered the problem while trying to add the KSOAP2 libs to the IDEA project, and although KSOAP has nothing to do with the problem, I may have imported them in the incorrect manner the first time and created extra self referential dependancies. This makes the most sense, but trying to figure out how to undo it would be next to impossible.
you can try to delete the r and buildconfig files from the com/x/x folder under android -> java
that fixed it for me.

Eclipse not creating new .java file in New Project wizard?

OK, I have a really basic (read stupid) question. I am just beginning Java programming, and am using Eclipse 3.7.2. I have done a few beginning projects without any problems. All of a sudden, when I create a new project using the wizard, it is not creating the src/.java file. When I try to manually add it after creating the project, I end up getting some cryptic error messages.
I have re-followed several walk-throughs on project creation for clues as to any option I may have accidentally un-checked and no luck.
Googling the answer brings up results for more advanced problems that are unrelated.
I have combed the preferences, but nothing looks obvious, and
I have gone hunting for any user app data I could delete to force a clean slate.
I have even created a new instance of Eclipse to a different directory and still have the same result.
My son's instance, which is on the same computer still creates the .java file from the wizard. The only difference is that my instances have the Android SDK installed (I am trying to create basic Java projects and not Android projects).
I am at a loss, and have lost a lot of time trying to correct the situation. What do I need to do to reenable the creation of a src/.java file in Eclipse?
Screenshots (click on image for full size):
Make sure you are choosing a java project from the right folder in the wizard. It sounds like it is creating an android java project, which is probably why your src folder is missing. See if there is a helloworld project under example projects too in the wizard, that may get you started too. Screenshot may help us. I want to see which project type you choose and which folder it is in.
How about changing eclipse to point to a new workspace. That may drop the android settings. Under the file menu, choose switch workspace and pick a new location. Thats most likely why a new install did not fix it. That workspace may have android settings in it, so change to a new folder somewhere else to test it like c:\workspace2\
Here's a good tutorial I found that may help too.
eclipse java project tutorial

Eclipse doesn't import java libraries on cold start, plus other compiling errors

Eclipse is giving me a few problems.
After a cold start and the loading of android libs, Eclipse underline the import statements or says that java.lang.Object couldn't be found.
Closing it and reopening often fix the problem. If it doesn't, another close-open fix it definitely. But it shows at each cold-start.
It also gives
"The type java.lang.Enum cannot be resolved. It is indirectly referenced from required .class files"
"The project cannot be build until build path errors are resolved"
But if i restart the build path errors and the enum problem are not show any more(sometimes the enum proble got fixed some time after eclipse's loading finished)
"Project 'xxx' is missing required source folder: 'gen' "
that should be generated automatically generated while building, and still restarting will fix them
In addition, in many projects, while building or cleaning, eclipse says that it couldn't delete the bin/. directory. I noticed that that directory is read-only, and if i try to remove the attribute(even from dos), it immediately return to read-only.
This problems aren't show-stoppers, i still can code and i still can get my apps exported, but it is quite annoying to have to restart eclipse a few times before being able to use it(and eclipse isn't that fast at opening), and i would really know how to fix it.
I searched in the net a bit, but i dind't found nothing useful or that worked.
Is there a way to fix them?
I didn't "unistalled"(it is just stored in a directory) Eclipse, since i should then reinstall android sdk, mercurial plugin, and re download and set up a few libraries i use in quite all my project, and i really hope there is another way.
final notes:
everything works when this problems doesn't show: the app works, logcat too, the right device is used to install the app, so i think java and android sdks are installed just right
I had that problem before so I just saved my projects to a different file and uninstalled everything ( java, android sdk, eclipse ). When I reinstalled it all I put the android sdk on the root of my c drive as I have a windows machine and then instead of picking where java was installed I let it do its own thing. I dont use a mercurial plug in but your "read only" problem could be related to that. Its possible your downloading files that are "read only" and there for you have no way to alter them. Im guessing since you said youve been programing you already know how to set the build paths and stuff. It might just be where everything is installed or something silly like privilege settings on your machine.
What were you using the mercurial plug in for anyway? just curious :)
Have you included the java lib in your project or? For a couple of weeks ago I sat with an project where i absolutly needed some of the methods, so because android just have some of the java lib I imported the need libs and used that.

IntelliJ and SVN: "no changes detected" upon commit

I'm trying to share a project between my desktop and laptop using Subversion. The project has 3 modules. I've imported the project folder into a repository in a shared folder that my laptop can access over the network.
I checked the project out on my laptop and then tried to open the project. None of the modules are visible, only the project's .iml file, as in the screenshot below.
I notice that the .iml file has a line for "content url", which refers to a location on my desktop. Maybe this is the problem. What can I do about it? Do I have to create a new project on the laptop and import the modules - so there would be 2 different top level .iml files, one for the desktop and one for the laptop? Am I going about this the wrong way?
UPDATE: The problem seems to be with committing. When I make a change in a file, save, and hit Commit Changes, I get a popup saying "No changes detected". This is the same on both laptop and desktop, and meant that I downloaded the wrong version onto my laptop before. I deleted the repository and created a new one, and my project works on my laptop now, but I can't commit changes from within IntelliJ (only with TortoiseSVN via file manager). Also, when I imported my project into version control from my desktop computer, the working copy wasn't put under version control. So I can't update from my desktop unless I check it out to a different folder.
I think there is something wrong with the SVN plugin with this version of IntelliJ (10.5.1). Does anyone else have problems with committing changes?
RESOLUTION I needed to
1) Update Settings | Version Control to map Subversion to the working directory
2) Import into Version Control
3) Check it out again
It may possibly have been caused by the fact that the modules were originally standalone projects which were in separate repositories. Whatever the cause, IntelliJ's "No changes detected" dialog isn't the most helpful.
VCS -> Refresh File Status solved this for me, when Intellij suddenly stopped noticing changes.
Please refer to the FAQ.
As for the content root, make sure that it's located under the project root or module root, in this case the path will be stored relatively to the project/modile root inside the iml file. If the fixed system specific path is used in the iml, such module will not work on other systems.
UPDATE:
Make an explicit mapping between the actual working directory and Subversion in Settings | Version Control dialog. If you are using the default placeholder and your project files are not under the checkout root, it could be the case.
After performing the initial import you need to do a checkout in order to use version control in IDEA.
Sometimes doing VCS -> Refresh File Status works for me.
Other times, it does nothing.
A solution is to
COPY all your file contents to clipboard / external notepad (for backup)
Choose Rollback on the file which needs updating. Now it is up-to-date with the server and does not contain your new changes.
Edit file again (checkout), and PASTE your original file contents.
Attempt to commit changes. It should detect them now.
I just ran into this today- checked out an existing project and had to update the SVN scheme from 1.6 (I think) to 1.8. That seemed to make Subversion not recognize that it was wrong it its belief- even though I could DIFF and see changes relative to the latest repository version- that "No Changes Detected."
I got so fed up that I shut down Intellij...on a whim I reopened it, and the file in question appeared blue...hmmm...yep, now it detected the changes.
I had the same issue it seems it may have been caused by having a file with the same name in two different GIT-repositories.
I was able to fix it by opening File -> Settings -> Version Control and then un-assigning and re-assigning GIT as the VCS of the two directories which both had the file. First the directory in which there was no changes in the file then the other active one which did have changes (but which did not detect them before).
I got into the similar issue today and I tried VCS -> Refresh File Status, but it didn't help me. When i looked at Version Control->Subversion Working Copies Information, i found an svn error The working copy at /home/project is too old to work with svn client 1.9.4. First i ran svn upgrade and then doing VCS -> Refresh File Status resolved my issue and i was able to commit my changes.
None of the other solutions here helped me.
Ended up checking out the entire repository again, copied all the sub folders over to the newly checked out folder and submitted the changes.
Deleted the old folder and renamed the new folder to the old folders name.

Categories

Resources