IntelliJ project files suddenly broken - java

I've been working on a project in IntelliJ IDEA for about two months now. Today, when I fired up the IDE, which would usually open project straight up, IntelliJ took unusually long time to load, and when it did open the project, the main .java file displayed a long line of spaces and nothing else, instead of the code that was there before. The .iml file, the only other thing in the project, was fine. An error message was on the top:
"This document contains very long lines. Soft wraps were forcibly enabled to improve editor performance."
Trying to edit the document results in the entire program freezing and becoming unresponsive. What the hell happened? It was fine one day and then just did this, how do I get my project back and how do I prevent this?

Solved in the comments below the question; thought I might as well post a dummy answer and mark this as resolved.
EDIT: Solution written out.
Right click on file > Local History > Show History
Find any suspicious changes in the list on the left. Be especially on lookout for "External changes", as those can indicate crashes and sudden power-outs. Alternatively, look for times when you remember your computer crashed or power went out while IntelliJ was open.
Revert the changes(curved purple arrow in the upper left corner). Restart the IDE if it's going slow. Everything should work properly now.

Related

Module not specified?

I have recently started learning android development, and I just built an app that changes color and text based on pushing buttons and gestures. It ran fine on my phone (Yay!), but then on my second run, an error occurred. When hitting the "run" button, an edit configurations window opened up:
I also noticed, that on the side where my project tree should be is this instead:
I don't think there is an issue in the code because it was running fine before, but I would be happy to post the code if needed.
Also
I dont know if this was the reason, but i'll include this anyway, I tried changing the name of my project, but it wouldn't work, but I changed it back. I included this in my question because that's literally the only thing I did before this error occured.
Thank you so much for helping out a fellow programmer, I really appreciate it. I have been looking at many other forums (for some hours) about this topic, but still couldn't trouble shoot this problem. It seems kind of odd that it was working first, and then it just randomly stopped working. I cant wait for your response!
Here is the dropdown for Module:
As you can see, that is the only option.
Are you sure you are opening the project as android gradle project ?
Try to import the program not open it

Running my new code runs my old code?

Somehow, whatever code I add to my program it does not run on my android device. It just runs my old code.
I am constantly deleting my app from my phone in the App Manager.
If I add new or change functionality the old code still runs.
I even delete complete blocks of code that should obliterate functionality. But somehow all the old functionality remains in the app after reinstall.
Simple example: On a TextButton click i shift some UI element by 200. This works great. When i delete the complete button listener it still works great but i guess completely by itself since the code should be gone.
I tried restarting Eclipse without luck.
This thing is driving me crazy. I was stuck for hours on some simple code and baffled why it did not run. Then I discovered my logs where not showing in logcat. Somehow, sometimes it does update the new code into the device since now i have a log on device resume but i deleted that at least 30 minutes ago and now it is still showing in my logcat.
Desktop app works as it should. I somehow have the feeling this happened before and over time this got worse, up to this point where i cannot test anything anymore.
So to be clear:
I add code to my app.
Run it from eclipse as Android application
No changes show up
Delete app from phone using the phones Application Manager
Delete a complete code block like the show() method that holds my complete stage
Run it from eclipse as Android application
App still runs as it was with the complete stage in tact.
-- edit --
Now I did not do anything to my code for a while and ran it. Now it probably took the code with the version with the empty show() method. However this already has been undone in the present. Could eclipse be stacking runs?
Check
"Project -> Build Automatically"
is checked. (Most likely your problem).
Also doing a
"Project -> Clean..."
tells the IDE to delete any previously compiled binaries and rebuilds them. (The APK file).
This could happen if there is an error in your code and you have selected run without warning when error in program exists. In such a case the last successfully built code would get pushed! As Lestat mentioned try doing a clean, if the project now shows up errors you have your culprit, else make sure your XML files are all proper.
Another check could be to see the timestamp of the last generated apk file in your workspace.
PS: There is a bug in eclipse where it doesnt save a file at time, a simple workspace restart fixes this.
Had the same issue - updated my code and yet the phone was running the old.
Tried Build --> Clean Project
Tried File --> Invalidate Caches/Restart
Now it works and recognizes the new code!
That said curious what #1 and #2 did behind the scenes??

Eclipse adt 23.02 does not work properly on program start

There's hard to name this problem so that i attach screen. It starts normally. All preferences seems to be ok. It has been restarted several times and it does not work. Can not open any perspective. Every option from main menu is disabled(grey text).
Regards

Real-time compilation in IntelliJ IDEA

I have recently switched from IntelliJ IDEA Community Edition version 12, to version 13 (updated to 13.0.1) and apparently the real-time ("on-the-fly") compilation of code does not work, at least not as found in other major IDEs (e.g., Eclipse).
A similar issue has been brought up in an earlier StackOverflow question and the answer was to check the corresponding option in File -> Settings -> Compiler, which I have of course done, but nothing changed.
The way it currently is, I can type whatever text in the Java code and there is no error highlighting, not even when the file is saved, let alone in real time.
Is there another setting or configuration that needs to be applied?
IntelliJ does something a lot better than compiling your files on the fly. It dynamically parses what you're typing, offering many more warnings than the java compiler produces. In comparison, compiling on the fly is a bad idea. Having said that, it sounds like you're having other problems, because you should have errors and other problems highlighted. At the top right of each editor window is a small coloured square. On good code it's green. It's yellow when there are warnings, and red when there are errors. If it's grey then Idea is analyzing your files. If you hover your mouse over the square it'll give you an idea about what Idea is doing, and how it's progressing. Try that before you try anything else. Idea never gets stuck, but it can run out of memory, if the analysis isn't progressing, then perhaps you've run out of memory, or have other issues, check this in the event log, which is at the bottom right of the window.
I've just been pulling my hair out over this working on my Mac in a coffeeshop running on battery power. Try File | Power Save Mode and make sure it's un-checked.

Recovering Source Code from Unfinished App on Android Phone

For the past month and a half I have been working on a project, an app for Android. Today my computer crashed. Apparently the backup didn't backup the source files for any of my projects though; it only backed up the drawable folders for some reason?
Anyway, I was wondering if there was a way to recover the source code from the app on the phone somehow. I never fully finished the app and created an .apk or anything, but I ran it on my phone several times for debugging purposes, so it is on my phone in a fairly recent state. Is there a way to somehow recover the source code for this? I would hate to have to redo anything, but it seems like I'm probably going to have to end up doing that.
I began the project in Eclipse Indigo but later switched IDEs to IntelliJ IDEA. The files I currently have on my computer are:
An EML file for the project. It appears to be blank.
The drawable folders
And that's it. Any ideas?
You can use dex2Jar to get a jar and then use JD-GUI to examine the code. Since it is decompiling it will not be exact, but close.
dex2jar: http://code.google.com/p/dex2jar/
JD-GUI: http://java.decompiler.free.fr/
You could look into this as an option:
It is a tool for reverse engineering 3rd party, closed, binary Android
apps. It can decode resources to nearly original form and rebuild them
after making some modifications; it makes possible to debug smali code
step by step. Also it makes working with app easier because of
project-like files structure and automation of some repetitive tasks
like building apk, etc.
http://code.google.com/p/android-apktool/
You can try file recovery softwares to get back your deleted files from your hard disk(if it is working).
These softwares worked for me in recovering pictures from a formatted SDCARD. So you can give it a try.
You may be able to use IntelliJ IDEA's "local history" feature. IntelliJ keeps track of all your edits in .IntelliJIdea10 folder in the use home. If that folder has not been damaged in the crash you should be able to recover all your codes.
Just right click on the module directory in the Project tab and select Local History > Show History. Wait for the list of history items to load, it may take a couple of seconds. Right click on an item in the left panel and select Revert.

Categories

Resources