I've quite new to Android development and specially Eclipse.
I'm busy on a project called, say 'HelloEclipse'. I've had some major changes ahead, in which I had to some very big changes.
So I made a zip file of c:\workspace\HelloEclipse, placed that in a save place. Went on to work on my project. Few hours later, I wanted to go back to the saved situation. Closed Ecplise, rebooted my computer, because I wanted to make sure there were no locked files. Deleted the old c:\workspace\HelloEclipse folder, place the version out of the ZIP file back.
This resulted in a totally corrupted workspace status. Could not go foward, nor backward. I've ended up, creating a new project, and pasted in everything, took me hours. I think this is quite stupid Eclipse behavior. I've also tried ot, export/import with a archive from out of Eclipse, also not succesfull.
So the two questions;
How am I suppose to save projects (without installing anything like subversion)?
Why is saving the files not enough, and why does that make Eclipse barf?
Thanks in advance!
Dennis
In eclipse if you want to reimport an old project from a ZIP, don't just copy the project files to the workspace, instead, extract the files to a normal dir outside the workspace.
Open Eclipse normally and select File>New Project>Android Project, just as you would to to create a new Android project, but then in the new android project window, you have a radio button giving you the choice to Create project from existing source, point it to the directory where you have extracted your old project and it should be re-imported to the WorkSpace alright.
Or do File>Import>Import existing project into workspace.
But in any case, don't put the files in the workspace manually to avoid conflicts, Eclipse will copy the files it needs itself upon importing.
There are hidden workspace files that you may have missed -- specifically, .classpath and .project. That said, it's a lot easier to make a backup copy (for example, of a released version so you can continue developing while supporting the release) by simply right-clicking on the top-level of the project in Eclipse and selecting Copy, then right-clicking and selecting Paste. The result will be a copy of the project after an opportunity to name the copy.
If you want to zip projects, you can do that by exporting them. If you want to delete existing projects, you should do that from inside Eclipse with a right-click. You can import the zip you previously exported.
If by save, you meant backing up the best something would be to create a local repository. If I were you, I would backup my code in an online repository too; to save it from hardware crashes or other disasters.
In your problem, you could have tried deleting the project alone and import the backup copy(from the zipped file) instead of deleting the entire workspace. Can't pinpoint the exact reason of why eclipse barfed but maybe because it messed up the workspace settings for eclipse. On a related note, I found this on the net.
Eclipse is rather troublesome at times but AFAIK it's the best IDE for android.
First of all, after several months of developing with eclipse I moved to IntelliJ (they have a community edition) and I found it much much better.
In intelliJ you can save local history, for example, you can set-up a label and go back to that label whenever you like without losing anything.
As for eclipse, you probably didn't zip some hidden files or something.
In addition, I remember having some similar problem, I had to resync the files with the project, try this one
Good Luck
I do the same thing with my projects. Instead of going through windows explorer to copy the files, I find copying the entire project from within Eclipse (right click the project in the explorer window pane, click copy, then click outside of the project and click paste) works just fine. When you paste it, you can specify a new save location and project name, which can be your backup space. Then you can switch between versions of the project no problem.
Related
I was working on a project. I deleted the project from the workspace (not from disk) temporarily to work on another project. I'm sure that I had saved my work before doing this. After finishing with second project I deleted it from workspace and imported the first project but there was nothing of my codes. Everything was removed. the files (classes, layouts, etc) all of them were in the project but they were empty. I checked the files on the disk and unfortunately saw that what is inside eclipse is real! All the files were empty and all my codes gone. I wanna ask WHY should this happen?
It happens to me also. You have to make a copy of your project on your disk first. Then you open it with eclipse and click to "copy projects into workspace" and then it works :)
Say if it's ok !
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 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).
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.
This is a dumb newbie question, but one that is driving me nuts.
I have an Android project being developed on Eclipse with two source files. Eclipse for some reason decided I didn't need one of the files and removed it from the project (i.e., I pushed the wrong key at the wrong moment). Now I only have one source file in my project. The lost source file is still there in the directory, but Eclipse just doesn't recognize it as part of the project. How do I get it back?
MY first suggestion is press F5 on the source folder.
Second suggestion, right click the project folder->Properties->Java Build Path -> Source - expand ".../src" and ensure your source file is not under the Excluded option.
Try dragging the file out of your folder onto the desktop, and then drag it from the desktop into your source folder in eclipse. I've had a handful of different situations where this was necessary.
Eclipse is really bugging me with this. I have an Android project that is not in the workspace. Since Android projects don't work correctly if you use Eclipse's Import>existing project you have to make a new Android project from a folder on disk. If this folder
is in your workspace, it won't work. If it isn't it works, but then the project is located outside of my workspace folder, which is irritating. Does anyone know a way around this?
You can fix this by following this alternative import flow:
Make sure your project folder you want to import is in your workspace folder
In Eclipse, go to File → Import...
Click General → Existing Projects into Workspace
Make sure the "Select root directory" radio button is selected, and browse to your workspace directory.
In the Projects box, check the box next to the project folder you want to import and click Finish.
This will properly import your Android project.
I've experienced this problem too, when, for example, I tried to create a new android project based on existing source (the Notepad Exercise 1 example program that the android developer's documentation provides). I believe the problem you are experiencing with Import not working is that what you are trying to import a "project" that isn't really an Eclipse project at all (e.g. no .project/.classpath - it's just source code with a directory structure that deceptively looks like a project).
Like cisteams has alluded to above, if this is the problem, the procedure around this goes something like this:
Make a new android project choosing "Create project from existing source", making sure that the source directory is indeed outside your workspace (you'll have to live with this for a second). This should a) make the necessary .project/.classpath files in the source directory (which is still outside your workspace for now) and b) make the project show up in your list in Eclipse.
Right click the project in the Package Explorer and choose Delete, making sure that the option to delete files on disk is unchecked when it comes up.
Now import the project like you would any other project (you can do this now because the .project/.classpath files were created in step 1 above). There should be an option when importing for "Copy projects into workspace", so tick that option.
And you should be done. You can go back now and delete the copy of the project that isn't in your workspace to avoid confusion later on.
What version of Eclipse and ADT are you using?
Currently this approach is working fine for importing projects that are checked out from SVN. It does require that you have a .project and .classpath files (normally they are checked in to revision control).
If you do not have these files (some open source examples don't include them) then you need to use the Android Wizard for creating a new Android project from existing source. The key here is that it is a New not an Import, so yes it doesn't like it if the files are in the workspace. What you can do is create the new project externally using the wizard to create the .project and .classpath files. Once those exist you can use the normal import to bring the files into your workspace (and check those missing files into your source control).
Also you must delete the current install on your phone or you will get a signature fail from other comps install of the same app. So do the above and uninstall app off your phone before running the app on the new computer.
Well, I hosed up my Android development PC, but didn't care all that much since I really needed a newer, much faster PC for this work. And here I am now with a high-end Windows 7 64-bit box.
Eclipse and all the Android components are up and running, but the one thing I'm having trouble with is how to get my previous project into the new workspace. I copied over my entire old workspace directory from the old disk and made that my Eclipse workspace, but it doesn't automatically see the projects that are there. I tried creating a new Android project "from existing source", but it complained about having "overlapping projects" or some such.
Is there a way to have it recognize the existing project files, or should I move them somewhere else, create the project from scratch, and then copy the old files back into the project tree? Or any other solutions?
A super easy way is by just doing an Import.
Select File Import.
Select Existing Projects Into Workspace and click next.
Select the directory of the project file.
Click Finish.
You will have to do this for each project. Note, that you may need to remove the project folder that you copied into the workspace manually, because this procedure will automatically copy the folder and hierarchy for you.
I used this method to code on my home machine as well as a development environment running from a live CD while attending classes in the computer lab.
Get Dropbox.
Put your workspace in a Dropbox folder.
Point the new machine's Eclipse install to your
Dropbox workspace folder after it
has updated itself.
Get back to coding.
Hope this works for you. It did for me.
There was one other complication. On my "old" PC I had been using Eclipse Helios, which apparently has some minor compatibility issues with ADT, so on my new PC I went with Galileo instead, and there might be some differences in existing files in the project directory.
In any case, what I did was to move my old project directory to a temp location, create a new project in Eclipse with the same name and basic settings, close Eclipse, copy my whole directory tree back into the new project directories, and then restart Eclipse. Eclipse bitched a bit about something, then went ahead and rebuilt everything.
I'm back in business! Thanks for all the responses.
BTW, the entire install process took a long time since I wasn't sure whether to install 64-bit Java or 32-bit (32-bit was required), etc. But it's nice to be running on a clean, fast PC instead of one that's been accumulating general crud for several years.
Move each of the projects in your hard disk to the new PC's workspace, or wherever you want to have them. Do not copy the metadata folder!. Then create new projects from existing sources (yes, you'll have to manually do this for each of the projects)
Ger
I know that this is old question but it is a issue I ran into when moving my project over from my home theater PC to my new laptop so I can leave my HTPC to doing HTPC things. Anyways what I did was I imported my project from over the computer over the network to my new laptop using new android project from existing code. The files where populated but it changed my root folder name. Being OCD I wanted to change the name of the root folder back to what I had on the other machine. I found if I right clicked the item in the project tree and selected refactor I could rename it back to what it was on my HTPC. This then resulted in my laptop having a exact working copy of the code so I can program from here.
You can copy whole Workspace just through import>General>Existing Projects into Workspace>Select root Directory>finish
Have you checked if the export/import eclipse mechanim works fine with 2 linked projects: android and app engine?