繁体   English   中英

如何将gradle项目转换为android项目

[英]How do I convert a gradle project to android project

我使用Eclipse ADT,我已经通过configure - >转换为gradle项目将我的android项目转换为gradle项目,实际上我需要将我的gradle项目转换为android项目。 我怎么能这样做?

您在Eclipse ADT中的Android项目通常应该有2个文件

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

一旦你纠正它们,你的项目就是Eclipse中标准的Android项目。

要从Eclipse使用更新的构建系统,请尝试使用Nodeclipse / Enide Gradle for Eclipse市场

Gradle for Eclipse的一些截图:

1.如果项目是在eclipse中创建的

您不需要将其转换为Eclipse项目,因为它已经是一个与Eclipse兼容的项目。 您只需将项目重新导入到您的工作区,它应该可以正常工作。

注意:将存在特定于gradle项目的文件,如build.gradle等(如果需要,可以删除)。

2.在gradle环境中处理

但是如果您直接在gradle中创建了项目:

通常,在build.gradle添加apply plugin: "eclipse"是一个简单的apply plugin: "eclipse"并且正在运行

cd myProject/
gradle eclipse

然后刷新Eclipse项目。

有时您需要调整build.gradle以某种非常具体的方式生成Eclipse设置。

如果你使用STS,那么EclipseGradle支持 ,但我不确定它有多好。

我知道唯一一个对gradle有原生支持的IDE是IntelliJ IDEA 它可以从GUI完全导入gradle项目。 您可以尝试免费的社区版。

暂无
暂无

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

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