如何使用 Eclipse 和 Mercurial 正确克隆 Android 项目

发布于 2024-10-18 14:51:48 字数 420 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

唠甜嗑 2024-10-25 14:51:48

我的做法如下:

  1. 使用命令行将存储库克隆到 Eclipse 工作区文件夹层次结构之外的单独文件夹中。

    hg clone https://existing/repository/path

  2. 在 Eclipse 中,使用“创建一个新的 Android 项目”从现有源创建项目”选项,选择克隆的文件夹。

选择“从现有源创建项目”

现在,新项目都是具有 Mercurial Team 选项的 Android 项目。

Here's what I do:

  1. Use command line to clone the repository in a separate folder outside of the Eclipse workspace folder hierarchy.

    hg clone https://existing/repository/path

  2. In Eclipse, create a new Android project using the "Create project from existing source" option selecting the cloned folder.

Select "Create project from existing source"

The new project is now both an Android project with the Mercurial Team options.

眼中杀气 2024-10-25 14:51:48

在 Eclipse Windows 中克隆 Android 项目

    Assume you have a WorkSpace at "D:\workspace" and want to clone an existing Android project named "B".

  1. :转到工作区
  2. Windows:制作名为“B”的完整项目目录的副本(Windows 制作“B - Copy”)
  3. Windows:将复制的目录“B - copy”重命名为克隆名称,在本例中为:“B_00”
  4. Windows:进入目录“B_00”并编辑文件“.project”
    将行更改为“B”进入“<名称>B_00”
    Windows:保存文件
  5. 启动 Eclipse 并在工作区中将其打开。 “B_00”不可见。
  6. Eclipse:菜单文件->导入
    Eclipse Import 对话框选择:选择General ->将现有项目放入工作区
    Eclipse 导入对话框选择:按下按钮“下一步”
    Eclipse 导入对话框导入项目:选择“选择根目录”,然后“浏览...”到“B_00”
    Eclipse 导入对话框导入项目:按“完成”按钮。
  7. Eclipse:包资源管理器:选择“B_00”
    Eclipse:菜单项目->干净的...
  8. 完毕。

Cloning an Android Project in Eclipse

    Assume you have a WorkSpace at "D:\workspace" and want to clone an existing Android project named "B".

  1. Windows: go to the WorkSpace
  2. Windows: make a copy of the complete project directory named "B" (Windows makes a "B - Copy")
  3. Windows: rename the copied directory "B - copy" into the clones name, in this case: "B_00"
  4. Windows: Go into directory "B_00" and edit file ".project".
    Change the line with "<name>B</name>" into "<name>B_00</name>"
    Windows: save the file

  5. Start Eclipse and open it in your WorkSpace. "B_00" is not visible.
  6. Eclipse: Menu File -> Import
    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.

  7. Eclipse: package explorer: select "B_00"
    Eclipse: Menu Project -> Clean...

  8. Done.
桜花祭 2024-10-25 14:51:48

我偶然发现了一个解决方案,并相信这些都是所需的步骤。

首先,我通过克隆现有的 Mercurial 项目创建了一个新项目,然后单击属性 -> Android 工具 ->转换为 Android 项目

添加了 PROJECT_DIR/.classpath 文件:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry kind="output" path="bin"/>
</classpath>

将 buildCommand/javabuilder 和 natures/javanature 行添加到 PROJECT_DIR/.project:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>SuperBetterThanEverythingElseApp</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.ApkBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>org.eclipse.jdt.core.javabuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>

然后我在 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:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry kind="output" path="bin"/>
</classpath>

Added the buildCommand/javabuilder and natures/javanature lines to PROJECT_DIR/.project:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>SuperBetterThanEverythingElseApp</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.ApkBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>org.eclipse.jdt.core.javabuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>

Then I closed the project in Eclipse, reopened it, added a missing external jar, did a Project -> Clean, and it worked.

不语却知心 2024-10-25 14:51:48

我刚刚为一个功能分支做了这个。我所做的只是在 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.

染火枫林 2024-10-25 14:51:48

从未使用过该插件,但一直在外部统一使用 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

十二 2024-10-25 14:51:48

在遵循最流行的答案时,我没有看到转换为 Android 项目的选项,因此我所做的就是:

  1. 使用“Mercurial Repositories”视图克隆远程存储库,而不创建项目。
  2. 使用您已签出的现有源代码创建一个新的 Android 项目。
  3. 如果您仍然没有看到正确的团队选项,请右键单击项目本身并选择“团队”>“团队”,让 Mercurial for Eclipse 了解该项目与存储库关联。 “共享”,然后是“Mercurial”。应该会出现存储库的本地克隆,只需选择它并保存更改即可。我只需要做一次,大多数时候前两步就足够了。

我最终得到了一个可以运行的 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:

  1. Clone the remote repository using the "Mercurial Repositories" view without creating a project.
  2. Make a new Android project using the existing source you've checked out.
  3. If you still don't see the right team options, make mercurial for Eclipse aware that the project is associated with a repository by right-clicking the project itself and selecting "Team" > "Share", then "Mercurial". The local clone of the repository should appear, just select that and save your changes. I only had to do that once, most times the first two steps are enough.

I ended up with a working Android project and am now able to interact with the repository using the normal "Team" menu commands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文