简体   繁体   English

Eclipse导入现有的android项目

[英]Eclipse import existing android project

I have this http://developer.android.com/shareables/training/Animations.zip demo project from google Training course. 我有这个来自Google培训课程的http://developer.android.com/shareables/training/Animations.zip演示项目。 When I import it in Eclipse: Import > Existing Android Code Into Workspace 在Eclipse中将其导入时:导入>现有Android代码到工作区 在此处输入图片说明

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. 如果我创建一个新项目,我会看到相同的东西:文件>新建>项目>现有代码中的Android项目也许还有导入项目的替代方法。

Vova, Vova,

Here's the deal. 这是交易。 Basically, that project does not have the .classpath or .project file. 基本上,该项目没有.classpath或.project文件。 If you are trying to open with Eclipse it needs the .project file. 如果您尝试使用Eclipse打开,则需要.project文件。 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. 如果您在工作空间中已经有一个已构建的项目,只需将.project和.classpath文件从该文件夹的根目录复制到AnimationsDemo的根目录(该项目的AndroidManifest.xml所在的文件夹)。 Simply open the .project file with a notePad c. 只需使用notePad打开.project文件即可。 In the tag 'name', change from your existing project's name to AnimationsDemo. 在标签“名称”中,从现有项目的名称更改为AnimationsDemo。

That's it. 而已。

Tell me if that works by accepting the answer! 接受答案,告诉我是否可行!

-Vivek -维维克

To do an import, you don't need a .classpath or .project file. 要进行导入,您不需要.classpath或.project文件。 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 我使用这个目录结构src / src / workspace

All my projects are in src/workspace. 我所有的项目都在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. 请注意,代码不必进入工作空间目录,但是我经常在src / workspace中创建项目及其代码。

If I'm importing code, I put the zip file in src/ and expand it there. 如果要导入代码,则将zip文件放在src /中,然后将其展开。

In Eclipse, I select Import > Existing Android Code Into Workspace. 在Eclipse中,我选择导入>现有Android代码到工作区。 Then I browse to the directory in src/ that contains the code I unzipped and click OK. 然后,我浏览到src /中的目录,其中包含我解压缩的代码,然后单击“确定”。

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/ . 我总是单击它的原因是,如果不这样做,Eclipse 将在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. 如果在尝试导入之前在包含代码的目录中进行了任何与Android相关的工作,则在尝试导入时会出现奇怪的错误。 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. 我只记得首先在Eclipse中创建项目, 然后在Eclipse之外做一些事情。 I regularly set up my projects in Eclipse first, and then modify them using "android update project". 我通常先在Eclipse中设置项目,然后使用“ 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. 而且,Ant是产生可发布代码的最佳方法。

改变工作空间对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM