Android Eclipse 导入现有代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14350484/
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
Android Eclipse Import Existing Code
提问by teynon
I am trying to organize my code for SVN so I can work from multiple locations without issue and potentially add more developers. The problem is that I can't get the code into a new project easily. I am trying to create a project from existing code.
我正在尝试为 SVN 组织我的代码,以便我可以在多个位置工作而不会出现问题,并且可能会增加更多的开发人员。问题是我无法轻松地将代码放入新项目中。我正在尝试从现有代码创建一个项目。
Once I select the folder, the "main activity" shows up, but I can never use it. I've tried deleting all the .project files and what not in the folder as well, but the thing is always greyed out and I can never get it to import.
一旦我选择了文件夹,“主要活动”就会出现,但我永远无法使用它。我已经尝试删除所有 .project 文件以及文件夹中没有的内容,但该内容始终呈灰色显示,我永远无法将其导入。
Why is it greyed out? What do I need to do to get it to import?
为什么显示为灰色?我需要做什么才能导入它?
-- ADT Build v21.0.0-519525
-- ADT Build v21.0.0-519525


回答by teynon
I played around with this a bunch and found out that it was conflicting with another similarly named activity that already existed in the workspace. The error message "Select at least one project" was covering up that message. It would appear very quickly and then switch to select at least one project.
我玩了一堆,发现它与工作区中已经存在的另一个类似命名的活动相冲突。错误消息“至少选择一个项目”掩盖了该消息。它会很快出现,然后切换到至少选择一个项目。
To get around this, I deleted all the projects from my workspace. I didn't know which one it was because I am making an app that is being versioned and branded for different companies.
为了解决这个问题,我从我的工作区中删除了所有项目。我不知道是哪一个,因为我正在制作一个应用程序,该应用程序针对不同的公司进行了版本化和品牌化。
回答by r_19
I had a hard time with the same problem with TrivialDrive. Try to check "Main Activity" from the project names you have in your workspace. if it exist, you'll get this error.
我在 TrivialDrive 上遇到了同样的问题。尝试从工作区中的项目名称中检查“主要活动”。如果存在,您将收到此错误。
回答by user1767754
Solution A:
解决方案一:
1) Close Eclipse, 2) when it starts it will ask for new working directory, choose something different then your default one.
1) 关闭 Eclipse,2) 启动时它会要求新的工作目录,选择与默认目录不同的目录。
if it is not asking for "new working directory"
如果不是要求“新工作目录”
Solution B: 1) Go to File > Switch Workspace > Other 2) Choose a new Working-Directory (not the same!)
解决方案 B:1) 转到文件 > 切换工作区 > 其他 2) 选择一个新的工作目录(不一样!)


After that it should be possible importing projects
之后应该可以导入项目
回答by Marat Levykin
It's grayed because project name equals to the name of existing project within workspace. Solution: Use "Existing Android Code Into Workspace" import. Type "Root Directory". Change "New Project Name" field directly in Import Projects wizard. Do the following: first press path text (right from checkbox) in "Project to Import" field then go to "New Project Name" field to change name.
它是灰色的,因为项目名称等于工作区中现有项目的名称。解决方案:使用“Existing Android Code Into Workspace”导入。输入“根目录”。直接在导入项目向导中更改“新项目名称”字段。执行以下操作:首先在“要导入的项目”字段中按路径文本(从复选框右侧),然后转到“新项目名称”字段以更改名称。
回答by user12305360
just go to eclipse-workspace and delete .metadata file restart eclipse open project
只需转到 eclipse-workspace 并删除 .metadata 文件重新启动 eclipse 打开项目
回答by Shylendra Madda
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. It worked for me..
只需删除项目文件夹中的“.project”文件(它在 Linux 上是隐藏的,使用“ls -a”显示),然后从 Eclipse 中选择 Create Android Project from existing source。它对我有用..
Thats it.Cheerzz..
就是这样。Cheerzz..
回答by Bandjalong
I had this problem when I needed to build an apk file as a one-off from an svn tag. I managed it by creating a new workspace and switching to it. After that New->Project->Android->Android Application From Existing Code worked as you would hope.
当我需要从 svn 标签一次性构建一个 apk 文件时,我遇到了这个问题。我通过创建一个新的工作区并切换到它来管理它。之后 New->Project->Android->Android Application From Existing Code 如您所愿。

