Eclipse Android Imported existing projects Accidently replaced and project all gone - java

I updated the ADT and imported the projects. Unfortunately, I replaced the projects/folder.
All of sudden, all the files in the folder became 0 bytes, including files in sub folders and all the current auto backups. Is there any other way to recover?and why this all 0bytes happened?
I had tested decompiling my apk from mobile with this and Differente decompilers. but, couldn't all the codes and obstucted codes. and most of the decompiler resulted errors.

I don't know what happened to your project but you can try to Restore from Local history :
Package Explorer view > Right click on file/project > Restore from Local history

Related

How to avoid Visual Studio Code warning: "[myfile].java is a non-project file, only syntax errors are reported"

I am running a build task in a Java project in Visual Studio Code.
The warning in the "PROBLEMS" tab:
[myfile].java is a non-project file, only syntax errors are reported
It refers to the first line where I load in the class file containing the main():
package [the project folder];
import [the project folder].[the file with other classes].*;
I can only avoid the warning by copying the files' text (the code text itself) into new Java files of a new project in a new unrelated folder. The code itself is correct and compiles without errors. Actually, this is the answer, but it is much manual work.
When I just copy the Java files of the project with the warning message into a new folder, the warning still appears!!!! (!)
When I just copy the whole project folder to a new place, the error remains as well, of course.
I guess that copying text into new Java files with the same names and the same folder structure is different from copying the files themselves because the files probably get tagged by Visual Studio Code, so that they have a project stamp even when the folder structure is destroyed. Perhaps this supports recovering the project structure from recovered raw files? Could this be the problem of this Visual Studio Code warning?
I checked other threads before, and this is just the last step.
How can I fix "build failed, do you want to continue"? In Visual Studio Code
Visual Studio Code - Java - Import Errors and More
--> Thus, I cleaned Visual Studio Code's workspaceStorage (on Windows: C:\Users\USER\AppData\Roaming\Code\User\workspaceStorage) and restarted without success.
Try cleaning the Java language server workspace:
Cmd + Shift + P (Ctrl + Shift + P on Windows) to show the command palette
Choose "Java: Clean the Java language server workspace"
Restart and Delete
It just worked for me.
I got the same warning simply because I had two Java (Maven) projects in the same Visual Studio Code workspace. Once I moved projectA out of the workspace, the warning for projectB was gone.
WorkspaceRoot
│ projectA
└───projectB
My current solution is to have one Java (Maven) project for one workspace, i.e, one Maven project per Visual Studio Code workspace.
My guess is that Visual Studio Code treats all Java projects inside the same workspace as as one project and hence, the projects interfering with each other.
This is an answer for those who do not use Maven.
The whole problem came up from loading not the direct project folder, but the parent folder, though the projects had been developed in their direct project folders from the start.
FOLDER1 (parent) contained
FolderA (direct project folder of Java files)
FolderB (direct project folder of Java files)
I have written the projects separately. But one time I opened the FOLDER1 in Visual Studio Code instead. That seems to have merged the two projects to just one project. After this, I changed back to opening only the FolderA/B and got the warnings that are reported in the question.
Now that I have opened FOLDER1 again and made both FolderA/B projects run without warnings (perhaps you might just comment out everything without fixing anything, but that is untested), opening the isolated FolderA/B projects threw no warnings either. It seems as if Visual Studio Code makes opening the parent folder the start of a new project which interferes with the child projects.
And the reason why I had a warning was a code error inside the other project's folder in the end (not important, but I had forgotten to load the local package needed for "FolderA" project at the start of some Java file).
Whatever error I had, the warning was confusing, as I was only working on project "FolderB" which had nothing to do with "FolderA" and which had no code issue. This led to the strange effect that I got the warning of the "FolderA" project also in my "FolderB" project, because Visual Studio Code considered both as one project.
I struggled with this for a long time, but I did not find a proper solution on the Internet. I somehow managed to do it by following these steps:
Here are the actions that I've performed:
There are folders you see in your left pane. (or press Ctrl + Shift + E to open the left pane).
Right-click on them one by one and press "Add folder to Java Source Path."
The one suggested in the solutions didn't solve my problem 100%. The problem with this extension occurred "Language Support for Java(TM) by Red Hat," which let our folder away from the source path.
Today I ran into this problem while going off-script during an Intro to Java tutorial video and somehow fixed it. This solution may not work for everyone.
Problems (1): [myfile].java is a non-project file, only syntax errors are reported.
How I fixed it...
I went to Java in Visual Studio Code and read sections "Working with Java source files" and "Working with Java projects". Basically, when working with "Java projects" in Visual Studio Code, you must have the necessary extensions installed to work with those project files.
In my case, I needed to build a Maven project supported through the extension "Language Support for Java by Red Hat" and "Server Connector by Red Hat", since one of the extensions did not come with Visual Studio Code's "Coding Pack for Java - Windows" or the "Java Development Kit: Amazon Corretto".
Once I had my extensions downloaded I opened the Command Palette (Ctrl + Shift + P) and typed "Java:Create Java Project" → "Maven" → "Maven-Archetype-Quickstart" → "1.4" → name] input group id → [name] input artifact id → then selected the folder I created that contained my Java file with the original error code (shown above). Once it was done processing, I reopened Visual Studio Code and opened my folder. Ran the program and the error went away.
You may have to copy/move your files manually or press Ctrl + Shift + E to open the left pane and add whatever you need to the Java Source Path.
I renamed the package which contains "[myfile].java is a non-project file, only syntax errors are reported" and it worked for me.
For me, removing the code folder in the C:\Users\yourHome\AppData\Roaming path solves the problem.
I have used the Visual Studio Code editor first-time for Java and I faced this issue with my simple Hello, World! program.
I tried to clean the editor's workspace, but the issue wasn't resolved.
Then, I created a folder named mypractice in the C:// drive. Following that, added the same in the Visual Studio Code workspace, and then created a Java file in that newly created workspace.
When I ran that file, it worked without any warnings or errors.
Instead of directly opening the Main.java file with Visual Studio Code Don't do this.
Open the folder in Visual Studio Code by selecting the 'Open with code' option after right clicking it in the folder and then run the program so it wont show that problem again Do this.
This is what helped me getting rid of that problem (Main.java is a non-project file, only syntax errors are reported), so I shared.
You should add your folder (in which your particular file is) to the workspace.
I have been running it a Dev Container/Docker image and multiple rebuilds have not been helping with this error. It has turned out I have accidentally created the directory in the root of the tree the current user had no access to. It has been the source of the issue.

Eclipse not launching? How do I save my projects?

I have been using eclipse to learn how to program Java and one day when I tried to use Eclipse it would not open. I get the purple window with a loading bar but when that gets about half way it crashes but does not give me any report as to why it crashed. How could I fix Eclipse or how could I save my projects so that I can reinstall Eclipse?
Your projects are already saved in your hard disk. You just need to reinstall, and when you open again to give the specific path to your projects.
Your projects (Eclipse workspace folder) are saved on your hard-drive . It has nothing to do with your Eclipse crash. If the folder is located inside Eclipse folder, just copy it to some other location. If it is already outside, you are safe.
If you re-install Eclipse, just use this copied workspace as your Eclipse workspace, it should just work fine.
Note: It would be easy to fix existing Eclipse, given you provide exact error message.
be cool , you can get your projects without any problem
1) go to eclipse.org ("https://eclipse.org/downloads/") and download eclipse and re-install then it will bind with your existing workspace in eclipse then you can open your projects through eclipse
2)eclipse default workspace is" C:\Users\yourname\workspace " manualy go to this link in here replace "yourname" with your PC name and get your projects

Unidentified R.java after blue screen of death

My computer crashed (Got the blue screen of death).
After that I was unable to open my project again, however, it's files were still present.
So I opened a new project and created all the files again and then copied the content inside.
Everything went well except for errors in all of my java files: "R cannot be resolved to a variable".
Additional info:
My Android SDK Build-tools are installed
The new project I created has the same name exactly, except for an aditional char "3" at the end of it [example: test3 instead of test],
and I editted the menifest file properly and also every java file to
contain the propper package name.
My R.java file is present [I'm using Eclipse, Windows7]
Would very appreciate help in solving this.
It is a quite common issue when using Eclipse for Android development but for some reasons, Eclipse isn't exit properly; re-opening the project will see the error logs of R.java ....
I suggest to remove the project from workspace (don't delete local files), copy your project source code to another directory. From Eclipse, File -> Open Existing Android Project, find the project source directory to re-add into workspace. Update the SDK version and dependencies. Usually, it should be fine at this step.
For experienced developers, I guess you know how to check file lock (#ChuongPham mentioned in comment above) and check for wrong resources references in projects manually...

Can't see files in project explorer in Eclipse android project

I'm working on an Android project. Something happened with my Eclipse project and I can no longer "see" any of my source files in the project explorer. The project explorer only shows :
src (clicking and trying to open yields nothing -- I can right click and open in a new window and see a bit more, but still can't decend the directory and see files)
gen
android.jar
usb.jar
maps.jar
My java files are still in the directory.
It looks like the project is corrupted somehow? I have tried deleting everything in .metadata/.plugins/org.eclipse.core.resources per some suggestions I've found but that doesn't seem to fix it. I created a new test project and it looked ok last night when I created it, although now, it to shows the same behavior as above. I'm using eclipse indigo service release 1. See the image bellow:
It's because you have the wrong view open. Try to open the Package Explorer
Window > Show View > Package Explorer

Eclipse does not refresh project files in package explorer view

Today I see a strange behaviour of Eclipse 3.5.2 for the first time in 3 months.
First, when I run a main function, it runs a previously compiled version. Let's say I press Ctrl+F11 in the window with an open java class and existing main function. Usually it rebuilds the class and runs a new version. Today even if there was a compile mistake, it would run fine. So I guess it does not recompile the class.
Next, more strangely, if I intentionally make a mistake in the code and Eclipse underlines those lines in red, still the project Explorer does not mark them as containing errors. They remain of grey color if there were not any errors.
First I did not know how to solve this problem. I tried to reopen the project, restart Eclipse and finally reboot the OS. After the tenth attempt, after rebooting, Eclipse said that all project's files are "OUT OF SYNC with the file system". When I pressed "Refresh" - F5 on a project's header name in Project Explorer it finally marked all the files with errors as containing errors and running the main function gave the desired result.
An hour of my work passed and this happened again , with the other project. All the same. No marking of files as red, running no matter what old version of class with no compile errors.
And since Eclipse does not tell that files are out of sync, simply pressing F5 on a project cannot help.
What can you suggest?
When you select a project in the Project Explorer view and press F5, Eclipse should traverse the entire directory tree for the project checking that all files and directories all in sync. It does for me ...
The only thing I can think of that would cause this not to work is if you have file system timestamp anomalies. For example, if a file in the file system is updated but the file's last-modified shows that it was updated in the past. This kind of thing can happen if your machine's system clock is moved backwards or forwards at an inconvenient time. If you think this might have happened, try closing all projects, restarting Eclipse and doing another F5 refresh.
(I used to run into Eclipse synchronization issues a lot, but I put that down to a combination of flakey plugins and doing builds from the command line. Either F5 or Project>Clean usually works for me.)
It is also worth checking that you haven't turned off "Build automatically"; see https://stackoverflow.com/a/2818290/139985. This is not a "refresh" problem, but it would be easy to confuse it with one.
Is Build automatically on? (Menu > Project > Build automatically)
It happened to me because there was a cyclic dependency between two projects. Each project had the other on its build path.
Solution: Reimport the project
It happened to me when checking out a new file from svn in explorer. Eclipse could not find the new file for some reason.
I tried refreshing the project(F5) and Project > Clean and build the project(Project > Build All) none of these worked for me.
So I deleted the project from the Project Explorer view(Not from hard disk). Make sure you unselect "Delete project contents on disk(cannot be undone)" checkbox and save any unsaved changes before you do this.
Now reimport the project using File > Import option. That should work in most cases.
If you use gradle, or something similar, instead of reimporting a project you can just regenerate the project files (gradle eclipse for example), and then you can refresh the project. Less cumbersome than deleting and reimporting.

Categories