Copying an Android Project Folder is Not a FULL Backup?

£可爱£侵袭症+ 提交于 2019-12-08 08:16:30

问题


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:

  1. Created an empty folder for the workspace,
  2. Switched Eclipse to it,
  3. 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 symptom 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 @Overrides 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 @overrides 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:

  1. Does Eclipse store additional information about the workspace elsewhere?
  2. What is a good approach to make Android projects more independent, as in "fully backup-able"?
  3. Is there any use for the .metadata/.log file? Can I safely delete it?

回答1:


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).




回答2:


  1. 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.

  2. 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.

  3. 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.



来源:https://stackoverflow.com/questions/6614103/copying-an-android-project-folder-is-not-a-full-backup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!