简体   繁体   English

将svn作为android项目运行

[英]Run svn as android project

i was looking all over the net but was unable to find solution for my problem, I imported project into eclipse Import -> Checkout Projects using Svn. 我一直在网上寻找,但找不到解决问题的方法,我使用Svn将项目导入eclipse Import-> Checkout Projects。 After the project was imported i tried to run it as android app but the project hasn't Android library, can't add library with right click -> build path, please help. 导入项目后,我尝试将其作为android应用程序运行,但是该项目没有Android库,无法通过右键单击->构建路径添加库,请提供帮助。

What you have just checked out is an android project. 您刚刚签出的是一个android项目。

But as there is no .project and .classpath files, this project is not set up to run with eclipse by default. 但是由于没有.project和.classpath文件,因此默认情况下该项目未设置为使用eclipse运行。

In order to have this project recognised as an Android project by Eclipse, you need to add the "Android Nature" to your project. 为了使该项目被Eclipse识别为Android项目,您需要在项目中添加“ Android Nature”。

The .project file is not visible from Eclipse but you can find it under the root directory of the Shelves project once you imported it into Eclipse. .project文件在Eclipse中不可见,但是一旦将其导入到Eclipse中,便可以在Shelves项目的根目录下找到它。

Edit your .project file and make it look like this : 编辑您的.project文件,使其如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Shelves</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>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ApkBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

Also make sure you checkout 还要确保您结帐

http://shelves.googlecode.com/svn/trunk/Shelves http://shelves.googlecode.com/svn/trunk/货架

and not 并不是

http://shelves.googlecode.com/svn/trunk http://shelves.googlecode.com/svn/trunk

You also have to create a .classpath file at the root of the Shelves project and make it look exactly as follows : 您还必须在Shelves项目的根目录中创建一个.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="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

Make sure your SDK is properly installed and your project.properties is targetting an installed SDK version. 确保正确安装了SDK,并且project.properties以安装的SDK版本为目标。 For example if you have SDK API-Level 10 installed : 例如,如果您安装了SDK API级别10:

# Project target.
target=android-10

Then close the project, open it again, make project > Clean..., refresh, bla bla bla ... until it works. 然后关闭项目,再次打开它,使项目> Clean ...,刷新,等等...直到起作用。

I don't believe that the given answer is the best practice. 我不认为给出的答案是最佳实践。 A lot of times projects in the repos do not have the .project or .classpath files (for good reason but that's a different story) so you can "create a project from existing source". 很多时候,回购中的项目都没有.project或.classpath文件(有充分的理由,但这是另外一个故事),因此您可以“从现有源创建项目”。

In eclipse there are two options that are similar yet different. 在Eclipse中,有两个相似但又不同的选项。 File->Import->Import Android Project... and File->New ->Project->Android->Android project from existing code. File-> Import-> Import Android Project ...和File-> New-> Project-> Android-> Android项目中的现有代码。 In the first, the .project and .classpath files are provided but you may have to tweak the build path. 首先,提供了.project和.classpath文件,但您可能必须调整构建路径。 In the latter, only the source is provided so that is the option you want to use. 在后者中,仅提供源,因此这是您要使用的选项。 Once you select 'Android project from existing code', just browse to the directory that you just checked out and then build the project. 选择“现有代码中的Android项目”后,只需浏览至刚刚签出的目录,然后构建该项目即可。

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

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