Copying an Android Project Folder is Not a FULL Backup?
Several weeks ago I took a snapshot of my Android project by simply copying the entire folder (Windows 7) to a network share.
A few weeks later, I wanted to build that snapshot in a new (and different) workspace. So I:
- Created an empty folder for the workspace,
- Switched Eclipse to it,
- Then used File > Import... to copy that snapshot to the workspace.
I was then surprised to find errors in the project - errors that weren't there before I copied it over to the network share.
The first symp开发者_JAVA百科tom was that only the last file in the project had multiple errors. I "fixed" that by entering into Eclipse (again!) Android's SDK location:
Windows > Preferences > Android > SDK Location: C:\android-sdk-windows
This resulted in numerous files now having errors, with the following hint at the console:
Android requires .class compatibility set to 5.0. Please fix project properties.
I fixed that by hovering over @override
and selecting the Change workspace compliance and JRE to 1.5
balloon suggestion. This is strange because I checked Windows > Preferences > Java > Compiler > Compiler compliance level:
and it was 1.6 before - Doesn't 1.6 include 1.5?
I was then left with only two errors stemming from @Override
s that shouldn't really be there (for methods implementing interface). So I removed them and now all is fine and the project builds and runs perfectly as before.
All nice and dandy but I was very surprised by the fact that I actually had to change anything in Eclipse, not to mention that I eventually ended up modifying the original source code (deleting @override
s only) to get it build - source code that had no complaints whatsoever weeks ago!
What could possibly explain this? Isn't copying an Android project folder a true full backup?
Being baffled by this discovery, I examined the workspace folder, using my beloved Emacs, and discovered that there is a hidden subdirectory named .metadata
. This is probably where the secret lies.
My questions now are:
- Does Eclipse store additional information about the workspace elsewhere?
- What is a good approach to make Android projects more independent, as in "fully backup-able"?
- Is there any use for the
.metadata/.log
file? Can I safely delete it?
I had those errors too when imported a project. If I'm remembering correctly, helped right-clicking in project name and selecting Android Tools -> Fix project properties...
After that errors disappeared.
“Android requires .class compatibility set to 5.0. Please fix project properties.” What’s this? It’s the error I received after cloning a repository and trying to import it into Eclipse. There is reasonably little information online about this, couple discussions on mailing lists but I figured I would write a post on the solution to this.
After importing the project to your workspace, you’ve received the error. So what you need to do next is to right click on the project -> Android Tools -> Fix Project Properties. Now this alone won’t fix the problem, you need to restart Eclipse after this. After that try building the project again and it should work successfully this time (unless you have bugs in the code itself, I did).
I've found that Eclipse's metadata is stored, as you found, in the ./metadata folder of your workspace. I do not believe there are any additional folders but I will double check.
The best way to do a back up of the android project if you are using eclipse is to export it by right clicking the project, selecting export and exporting it as an archive, file system, etc. That way you can be sure you've backed it up in a way that Eclipse knows how to handle it.
Rather than delete it, why not make a copy of it first? Edit: I would also take a look at running
eclipse.exe -clean
in the command terminal. That may be more useful than manually deleting the .metadata folder.
精彩评论