如何使用 Eclipse 和 Mercurial 正确克隆 Android 项目
我正在尝试使用 Eclipse、Android SDK 和 Mercurial 插件克隆 Android 项目。我可以通过执行以下操作成功克隆它:文件 ->新->项目->克隆现有的 Mercurial 存储库
但是当 Eclipse 似乎无法识别它是一个 Android 项目时,问题就开始了。然后我可以右键单击该项目并:Android Tools ->转换为 Android 项目,但我无法选择任何构建首选项,并且源文件夹图标未被识别为包。我尝试添加一个新包,但 Eclipse 说该文件夹不是 Java 源文件夹。
我觉得存储库、我克隆它的方式有问题,或者 Eclipse/Mercurial/Android SDK 不能很好地协同工作。
显然,我对此完全是新手,感谢您的帮助/耐心。欢迎提供有用教程的链接,因为我发现没有一个教程涉及这组特定的工具。
I'm trying to clone an Android project using Eclipse, the Android SDK, and the Mercurial plug-in. I can successfully clone it by doing this: File -> New -> Project -> Clone Existing Mercurial Repository
But the problems start when Eclipse does not seem to recognize that it is an Android project. I can then right-click on the project and: Android Tools -> Convert to Android Project but I don't get to select any build preferences and the source folder icon doesn't get identified as a package. I try to add a new package but Eclipse says the folder is not a Java source folder.
I feel like there is either something wrong with the repository, the way I am cloning it, or that Eclipse/Mercurial/Android SDK don't work well together.
Obviously, I'm a complete greenhorn at this and any help/patience is appreciated. Links to useful tutorials are welcome since none that I've found deal with this particular set of tools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我的做法如下:
使用命令行将存储库克隆到 Eclipse 工作区文件夹层次结构之外的单独文件夹中。
hg clone https://existing/repository/path
在 Eclipse 中,使用“创建一个新的 Android 项目”从现有源创建项目”选项,选择克隆的文件夹。
现在,新项目都是具有 Mercurial Team 选项的 Android 项目。
Here's what I do:
Use command line to clone the repository in a separate folder outside of the Eclipse workspace folder hierarchy.
hg clone https://existing/repository/path
In Eclipse, create a new Android project using the "Create project from existing source" option selecting the cloned folder.
The new project is now both an Android project with the Mercurial Team options.
在 Eclipse Windows 中克隆 Android 项目
Assume you have a WorkSpace at "D:\workspace" and want to clone an existing Android project named "B".- :转到工作区
- Windows:制作名为“B”的完整项目目录的副本(Windows 制作“B - Copy”)
- Windows:将复制的目录“B - copy”重命名为克隆名称,在本例中为:“B_00”
- Windows:进入目录“B_00”并编辑文件“.project”。
B ”进入“<名称>B_00” - 启动 Eclipse 并在工作区中将其打开。 “B_00”不可见。
- Eclipse:菜单文件->导入
- Eclipse:包资源管理器:选择“B_00”
- 完毕。
将行更改为“
Windows:保存文件
Eclipse Import 对话框选择:选择General ->将现有项目放入工作区
Eclipse 导入对话框选择:按下按钮“下一步”
Eclipse 导入对话框导入项目:选择“选择根目录”,然后“浏览...”到“B_00”
Eclipse 导入对话框导入项目:按“完成”按钮。
Eclipse:菜单项目->干净的...
Cloning an Android Project in Eclipse
Assume you have a WorkSpace at "D:\workspace" and want to clone an existing Android project named "B".- Windows: go to the WorkSpace
- Windows: make a copy of the complete project directory named "B" (Windows makes a "B - Copy")
- Windows: rename the copied directory "B - copy" into the clones name, in this case: "B_00"
- Windows: Go into directory "B_00" and edit file ".project".
- Start Eclipse and open it in your WorkSpace. "B_00" is not visible.
- Eclipse: Menu File -> Import
- Eclipse: package explorer: select "B_00"
- Done.
Change the line with "<name>B</name>" into "<name>B_00</name>"
Windows: save the file
Eclipse Import dialog Select: select General -> Existing Projects into Workspace
Eclipse Import dialog Select: push button "Next"
Eclipse Import dialog Import Projects: select "select root directory" and then "Browse..." to "B_00"
Eclipse Import dialog Import Projects: push button Finish.
Eclipse: Menu Project -> Clean...
我偶然发现了一个解决方案,并相信这些都是所需的步骤。
首先,我通过克隆现有的 Mercurial 项目创建了一个新项目,然后单击属性 -> Android 工具 ->转换为 Android 项目
添加了 PROJECT_DIR/.classpath 文件:
将 buildCommand/javabuilder 和 natures/javanature 行添加到 PROJECT_DIR/.project:
然后我在 Eclipse 中关闭了该项目,重新打开它,添加了缺少的外部 jar,做了一个项目 ->干净,而且有效。
I've stumbled upon a solution and believe these were all of the steps needed.
First I created a new project by cloning an existing mercurial project and clicked Properties -> Android Tools -> Convert to an Android Project
Added a PROJECT_DIR/.classpath file:
Added the buildCommand/javabuilder and natures/javanature lines to PROJECT_DIR/.project:
Then I closed the project in Eclipse, reopened it, added a missing external jar, did a Project -> Clean, and it worked.
我刚刚为一个功能分支做了这个。我所做的只是在 Eclipse 工作区的另一个目录中创建现有项目的克隆,然后在 Eclipse 中打开克隆的项目。
我没有使用 MercurialEclipse 插件来创建克隆,而是使用了 TortoiseHg Workbench 中的File->Clone Repository 菜单项。然后,我从 Eclipse 中调用File->Import->Projects from Local Mercurial Repository菜单项,将新项目添加到工作区。您还应该能够通过调用 hg.exe 从命令行创建克隆(hg help clone 将为您提供要使用的命令行选项)。
您没有提及您正在使用的软件版本。我在 Windows 7 上使用 TortoiseHG 2.0.2、Eclipse Helios Service Release 2 和 MercurialEclipse 1.8.0。
I just did this for a feature branch. All I did was create a clone of the existing project in another directory in the Eclipse workspace, then opened the cloned project in Eclipse.
I did not use the MercurialEclipse plugin to create the clone, I used the File->Clone Repository menu item in the TortoiseHg Workbench. I then called the File->Import->Projects from Local Mercurial Repository menu item from Eclipse to add the new project to the workspace. You should also be able to create the clone from the command line by calling hg.exe (hg help clone will give you the command line options to use).
You don't mention the software versions you are using. I'm using TortoiseHG 2.0.2, Eclipse Helios Service Release 2, and MercurialEclipse 1.8.0 on Windows 7.
从未使用过该插件,但一直在外部统一使用 Mercurial 用于我的所有项目(也非 Android)。为什么不尝试在外部设置存储库。 http://redline6561.livejournal.com/362393.html
Never used the plugin but have been using mercurial externally and uniformly for all my projects (also non-android). Why not try setting up the repository externally. http://redline6561.livejournal.com/362393.html
在遵循最流行的答案时,我没有看到转换为 Android 项目的选项,因此我所做的就是:
我最终得到了一个可以运行的 Android 项目,现在可以使用普通的“团队”菜单命令与存储库进行交互。
I didn't see the option to convert to an Android project when following the most popular answer, so here's what I did instead:
I ended up with a working Android project and am now able to interact with the repository using the normal "Team" menu commands.