如何将现有的 Android 项目导入 Eclipse?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2231474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:04:20  来源:igfitidea点击:

How to import existing Android project into Eclipse?

androideclipse

提问by paul

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.

我正在尝试将现有的 Android 项目导入到我当前的 Eclipse 工作区中。我选择 File->New->Android Project,这会打开 Android 项目对话框,然后选择“从现有源创建项目”、位置、构建目标和完成。

I get the following error: Invalid project description.

我收到以下错误:无效的项目描述。

Does anybody know how to get past this error?

有人知道如何克服这个错误吗?

采纳答案by paul

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.

解决:如果要“从现有源创建项目”,则需要创建一个新目录,然后将项目目录树放入该新目录中。然后在导入时指向新目录。

回答by James Wald

  1. File → Import → General → Existing Projects into Workspace → Next
  2. Select root directory: /path/to/project
  3. Projects → Select All
  4. Uncheck Copy projects into workspaceand Add project to working sets
  5. Finish
  1. 文件 → 导入 → 常规 → 现有项目到工作区 → 下一步
  2. 选择根目录: /path/to/project
  3. 项目 → 全选
  4. 取消选中Copy projects into workspaceAdd project to working sets
  5. 结束

回答by 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 workspaceand then import

将您的源代码放在任何现有工作区之外的目录中,然后导入

回答by 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

只需删除项目文件夹中的“.project”文件(它在 Linux 上是隐藏的,使用“ls -a”显示),然后从 Eclipse 中选择 Create Android Project from existing source

回答by 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.

我发现 James Wald 的答案最接近我的解决方案,除了“File->Import->General->Existing Projects into Workspace”(这对我根本不起作用)我使用“File->Import->Android- >将现有 Android 代码导入工作区”。我正在使用 Helios,也许您的 Eclipse 版本没有这个怪癖。

回答by Ullash

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

您也可以使用 Make new > General > Project,然后将项目导入到该项目目录

回答by 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.

我不确定这会解决您的问题,因为我不知道它来自哪里,但是当我导入一个项目时,我会转到文件 -> 导入 -> 现有项目到工作区。也许它会规避你的问题。

回答by 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.

似乎您无法拥有项目根目录,AndroidManifest.xml 比工作区根目录下的目录级别更深。在我放弃并重新安排我的回购之前,我为此挣扎了一个小时。

回答by thera

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

从 SVN 检出 Android 项目时遇到错误问题。这就是我所做的,整个事情都安定下来了。
1. 像我们通常做的任何其他项目一样从 SVN 签出项目
2. 右键单击​​并获取项目的属性
3. 在 java build path->order and export 选项卡中选择 android API 并确定它

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


到目前为止,这消除了所有项目问题,但不确定这是否是 100% 正确的方法