1

I have this http://developer.android.com/shareables/training/Animations.zip demo project from google Training course. When I import it in Eclipse: Import > Existing Android Code Into Workspace enter image description here

I see the same thing if I create a new Project: File > New > Project > Android Project from Existing code Maybe there is alternative method to import a project.

vovahost
  • 34,185
  • 17
  • 113
  • 116
  • 4
    So, your question is that you are unable to import the project? If yes, then one reason might be that a project with the same name exists in the workspace. If a project with same name exists, then rename it and then import this one. – Shobhit Puri Apr 05 '13 at 23:16
  • I've also seen this in Windows 7 when the project is in the workspace directory, but not yet imported. This causes Eclipse to try to overwrite the code with the code that's already there. I've solved that by moving it to a different directory. – DigCamara Apr 05 '13 at 23:21
  • ^ Extremely right. As DigCamera suggests, either move the old project to a new directory from workspace or you may rename the old project. Both should work ideally. – Shobhit Puri Apr 05 '13 at 23:31
  • @Shobhit Puri, I don't have project with the same name in the workspace, please see **vkinra** answer. – vovahost Apr 06 '13 at 10:41

3 Answers3

7

Vova,

Here's the deal. Basically, that project does not have the .classpath or .project file. If you are trying to open with Eclipse it needs the .project file. So simply put, do this:

a. If you already have a built project in the workspace, just copy the .project and .classpath file from that folders root into the root of AnimationsDemo (the same folder where the AndroidManifest.xml is for that project) b. Simply open the .project file with a notePad c. In the tag 'name', change from your existing project's name to AnimationsDemo.

That's it.

Tell me if that works by accepting the answer!

-Vivek

vkinra
  • 943
  • 1
  • 9
  • 16
  • 1
    This worked but now R.java is missing and I can't do nothing. This http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating didn't help me. – vovahost Apr 06 '13 at 01:22
  • 1
    Vova, that looks like a different question. But I will try to help, is there any errors in the xml file? – vkinra Apr 06 '13 at 05:18
  • 1
    There are errors but all are related to R.java. 1) In some java files: R cannot be resolved to a variable 2) In AndroidManifest.xml: errror:No resource identifier found to attribute 'parentActivityName' in package 'android' – vovahost Apr 06 '13 at 10:50
1

To do an import, you don't need a .classpath or .project file. However, you do need to point to a directory that's outside the workspace that's the target for your new project.

I use this directory structure src/ src/workspace

All my projects are in src/workspace. Note that the code doesn't have to go into the workspace directory, but I often create projects and their code in src/workspace.

If I'm importing code, I put the zip file in src/ and expand it there.

In Eclipse, I select Import > Existing Android Code Into Workspace. Then I browse to the directory in src/ that contains the code I unzipped and click OK.

At this point, I'm in the same dialog you included. I usually change the project name, and I always click Copy projects into workspace.

The reason I always click it is that if I don't, Eclipse creates the project in the directory in src/. That isn't a good idea if you want a pristine copy of the sample you're importing. If I click Copy projects into workspace, I'm always working with a copy, not the original.

If you do any Android-related work in the directory containing the code before you try to import, you'll get weird errors when you try to import. I'm not sure if this is a bug or not. I just remember to create the project first in Eclipse, and then do stuff outside Eclipse. I regularly set up my projects in Eclipse first, and then modify them using "android update project". This allows me to work on the project with command-line tools more readily. Also, Ant is the best way to produce releasable code.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18
0

Changing the workspace worked for me.

Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126