简体   繁体   中英

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. 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.

What you have just checked out is an android project.

But as there is no .project and .classpath files, this project is not set up to run with eclipse by default.

In order to have this project recognised as an Android project by Eclipse, you need to add the "Android Nature" to your project.

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.

Edit your .project file and make it look like this :

<?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

and not

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 :

<?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. For example if you have SDK API-Level 10 installed :

# Project target.
target=android-10

Then close the project, open it again, make project > Clean..., refresh, bla bla bla ... until it works.

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".

In eclipse there are two options that are similar yet different. File->Import->Import Android Project... and File->New ->Project->Android->Android project from existing code. In the first, the .project and .classpath files are provided but you may have to tweak the build path. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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