ChatGPT解决这个技术问题 Extra ChatGPT

How to import existing Android project into Eclipse?

I'm trying to import and existing Android project into my current Eclipse workspace. I select File->New->Android Project, which brings up the Android project dialog, I then select, "Create project from existing source", Location, Build Target and Finish.

I get the following error: Invalid project description.

Does anybody know how to get past this error?

I changed the workspace location to a new directory, it seemed to have fixed this problem.

J
James Wald

File → Import → General → Existing Projects into Workspace → Next Select root directory: /path/to/project Projects → Select All Uncheck Copy projects into workspace and Add project to working sets Finish


@JamesWald, when exporting to later import, should I Select All the tree of the project to export rather than only the source? I definitely want the res folder too.
I've never actually tried to export. It seems to import using the working copy as-is. Try to copy the entire project root and then import it.
@James Wald I got it. Thank u.
this isn't work if the project is originally created in NetBeans, gives "Invalid project description."
@akoskm: NetBeans manages projects in a totally different way than Eclipse. In this case you follow: 'File > New > Project... > Android > Android Project from Existing Code'
C
Community

Solved: If you want to "Create project from existing source", you need to create a new directory and then put the project directory tree into that new directory. Then point to the new directory when importing.


This is quite a messy solution. I recommend the import-> general -> existing project. Having to crate new folders and copy things around seems like unnecessary extra work and confusion.
I took this approach but ran into one issue, I wanted my workspace to be in the parent folder of what I was importing. If you take this approach, you must name your project the same name as the folder so it can find the source.
The write, docmented solution is the one of James Wald. All other 'findings' and 'patches' are misleading and ouf of a professional status.
J
James Bayley

This error message appears when the source code you try to import is inside an existing workspace.

Put your source code in a directory OUTSIDE any existing workspace and then import


Exactly. Your solution worked for me. Do you know any reason behind this?
Thanks James. Finally i known why i can't import my old projects existing in workspace and solved it.
Wohoo - worked! It's sad that this issue still exists after so long without any handling by the IDE or at least a notice.
IMO this should be the accepted answer. I was fighting a lot with this issue just because I always put existing code in my current Eclipse workspace
How does this work with SVN/GIT? I checkout my project to some directory and then import it to the workspace, which changes it's path, therefore it is disconnected from my SVN/GIT client.
t
thucnguyen

Just delete the ".project" file in your project folder (it's hidden on Linux, use "ls -a" to show), then from Eclipse, choose Create Android Project from existing source


This was exactly my problem, and simply deleting the .project file nailed it! Poof! Instant success following this procedure. Thanks so much
p
pgsandstrom

Im not sure this will solve your problem since I dont know where it originats from, but when I import a project i go File -> Import -> Existing projects into workspace. Maybe it will circumvent your problem.


Thanks, but there is nothing on the import dialog that points to an Android project. For any other type of project, that would be ok.
@paul File -> Import -> Existing projects into workspace should work for any project type, including Android projects, as long as it is a valid Eclipse project.
The above path should be File -> Import -> General -> Existing projects into workspace. I imported there and it worked like a charm.
Thank you, i was looking for this exactly.it dose not requires to move my project to other location.
S
Sebastian Brannstrom

It seems you cannot have your project root, with the AndroidManifest.xml deeper than one directory level below your workspace root. I struggled for an hour with this before I just gave up and rearranged my repo.


Y
Yi Jiang

You can also use Make new > General > Project, then import the project to that project directory


A
Arthulia

I found James Wald's answer the closest to my solution, except instead of "File->Import->General->Existing Projects into Workspace" (which did not work for me at all) I used "File->Import->Android->Existing Android Code Into Workspace". I am using Helios, maybe your version of Eclipse does not have this quirk.


B
Bo Persson

I had the problem of getting errors when checking out an Android project from SVN. This is what I did and the whole thing settled down. 1. checkout the project from SVN as we normally do any other project 2. right click and get properties of the project 3. In the java build path->order and export tab select the android API and OK it

this removed all the project issues so far so good but not sure if this is the 100% correct method


u
l
laaptu

In my Android Project folder .project file was missing. Restoring the .project file,which will be hidden in Unix OS environment resolved the error.


N
Neil Townsend

Updating @JamesWald's answer, and incorporating other comments. Assuming you want to create a cfesh copy from, say, a backup in your new workspace:

Put the existing project in a directory not inside the destination workspace. In Eclipse: File->Import->Android->Existing Android Code into Workspace, Next Select root directory: /path/to/project/from/step/1 Projects->Select All (or not, as the case may be) Make sure you set the new project name correctly - To change one click on the old project name (left column) and then click on the new project name (right column) and then edit. It will default to the class name of the Default Activity. Assuming you want a copy in the destination workspace, check "Copy projects into workspace" uncheck "Add project to working sets" Finish


A
Ambegodas

Same problem happened to me as well and the .project file was not there in the project. I copied a .project file from an existing android project and replace the project name with the name of the project I am trying to import. Then using File -> Import -> Existing projects into workspace I was able to import the project.


T
Tony Vu

What works for me is that: File > Import > Existing Project into Workspace (under General tab), then choose the project root folder. The importing of Existing Android Code into Workspace somehow does not work on Eclipse for me.