复制一个Android项目文件夹不是一个完整的备份?文件夹、备份、完整、不是

2023-09-07 09:17:37 作者:_.酒吧戀情′

几个星期前,我把我的Andr​​oid项目的快照通过简单地复制整个文件夹(Windows 7)到网络共享。

几个星期后,我想建立一个新(不同)工作区快照。所以我:

创建一个空文件夹的工作区,切换Eclipse来了,然后使用File >导入复制该快照到工作区。

我当时惊讶地发现,在该项目的错误 - 之前,我复制过来到网络共享被认为不存在错误。

第一个症状是,只有在项目的最后一个文件有多个错误。我通过进入Eclipse的固定Android的SDK位置(再一次!)

Windows和GT; preferences> Android和GT; SDK位置:C:\\ Android的SDK窗口

这导致了大量的文件,现在有错误,与控制台以下提示:

Android的需要的.class兼容性设置为5.0。请修复项目属性。

我固定,通过悬停在 @override 并选择更改工作区合规性和JRE 1.5 气球建议。这很奇怪,因为我查 Windows和GT; preferences> Java的>编译器>编译器的级别:,这是以前1.6 - 不包括1.6 1.5

我当时只有两个错误从 @覆盖取值所产生的,并不是真的应该有(实现接口方法)离开了。所以我删除他们,现在一切都很好,项目建造和运行完全像以前一样。

所有美好和花花公子,但我的事实很奇怪,我其实是有改变的任何的在Eclipse中,更何况,我终于结束了修改原始出处code(删除 @override 唯一),以获得其打造! - 源$ C ​​$ C,它没有任何投拆星期前

怎么可能解释一下吗?是不是照搬一个Android项目文件夹一个真正的完全备份?

这个发现正在百思不得其解,我检查了工作区文件夹,用我心爱的Emacs,发现里面有一个名为隐藏的子目录 .metadata 。这可能是那里的秘密所在。

我的问题现在:

确实Eclipse的存储的其他有关工作区的信息在其他地方?什么是一个好方法,使Android的项目更独立,如完全备份能够?是否有任何的使用 .metadata / .LOG 文件?我可以放心地删除吗?解决方案

我有这些错误太导入的项目时。如果我记得正确的,有助于右键点击项目名称,选择Android的工具 - >修复项目属性...

之后的错误消失了。

  

要求的Andr​​oid兼容的.class  设定为5.0。请修复项目  属性。这是什么?这是  错误我克隆后收到  资源库,并试图将其导入  到Eclipse中。有合理  小信息网上关于这一点,  在邮件列表讨论的情侣  但我想我会写一个帖子  解决这个

    

导入项目后,你的  工作区,您收到的错误。  所以,你需要做什么接下来就是  右键单击项目 - > Android版  工具 - >修复项目属性。现在  这本身并不能解决问题,你  需要在此之后重新启动Eclipse。  之后,尝试构建项目  再次,它应该成功运行  这一次(除非你在错误  code本身,我做了)。

Several weeks ago I took a snapshot of my Android project by simply copying the entire folder (Windows 7) to a network share.

eclipse如何将复制的android项目变成一个新的项目

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 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:

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

 
精彩推荐