Human
Human

Reputation: 10815

How do I convert a gradle project to android project

I use Eclipse ADT and i have convert my android project to gradle project through configure -> convert to gradle project, actually i need to convert my gradle project to android project. How i can do that ?

Upvotes: 4

Views: 3210

Answers (2)

Paul Verest
Paul Verest

Reputation: 63902

Your Android project in Eclipse ADT usually should have 2 files

.project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Android-app</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>

.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 exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

Once you correct them, your project is back standard Android project in Eclipse.

To use newer build system from Eclipse try Nodeclipse/Enide Gradle for Eclipse (marketplace)

Some screenshots for Gradle for Eclipse:

Upvotes: 2

kAnNaN
kAnNaN

Reputation: 3679

1.If project is created in eclipse

You don't need to convert it to an Eclipse project, because its already an eclipse compatible project. You just need to re-import the project into yo your workspace and it should work fine.

Note: There will be files specific to gradle project like build.gradle, etc. (you can delete if you want to).

2.Created in gradle environment

But if you have created the project in gradle directly:

Usually it is a simple as adding apply plugin: "eclipse" in your build.gradle and running

cd myProject/
gradle eclipse

and then refreshing your Eclipse project.

Occasionally you'll need to adjust build.gradle to generate Eclipse settings in some very specific way.

There is gradle support for Eclipse if you are using STS, but I'm not sure how good it is.

The only IDE I know that has decent native support for gradle is IntelliJ IDEA. It can do full import of gradle projects from GUI. There is a free Community Edition that you can try.

Upvotes: 1

Related Questions