【问题标题】:How do I convert a gradle project to android project如何将 gradle 项目转换为 android 项目
【发布时间】:2014-03-30 13:57:58
【问题描述】:

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

【问题讨论】:

    标签: android eclipse gradle


    【解决方案1】:

    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 (marketplace)

    Gradle for Eclipse 的一些截图:

    【讨论】:

      【解决方案2】:

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

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

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

      2.在gradle环境中创建

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

      通常很简单,只需在 build.gradle 中添加 apply plugin: "eclipse" 并运行

      cd myProject/
      gradle eclipse
      

      然后刷新您的 Eclipse 项目。

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

      如果您使用的是 STS,则有 gradle support for Eclipse,但我不确定它有多好。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-27
        • 2015-12-13
        • 2017-12-07
        • 1970-01-01
        • 2012-09-21
        • 1970-01-01
        相关资源
        最近更新 更多