是否可以使用Eclipse与Eclipse的Gradle构建系统? [英] Is it possible to use the Gradle build system for Android with Eclipse?

查看:77
本文介绍了是否可以使用Eclipse与Eclipse的Gradle构建系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要为不同的客户(品牌,配置和预先加载的客户之间的数据更改)使用不同的资源多次构建。

I've an app that needs to be build multiple times with different resources for different customers (branding, configuration, and pre-loaded data change between customers).

在今年的Google I / O之后,我听说过有关基于Gradle的新版Android构建系统。所以我想,这将是一个好主意,使用Gradle构建脚本来实现这个单源/多方案场景。

In the wake of this year's Google I/O I've heard about the new Gradle-based Android build-system. So I thought, it would be a good idea, to realize this one-source/multiple-apks scenario using a Gradle build script.

现在我的问题是:我可以在坚持Eclipse的时候开始使用Gradle进行构建吗?我在网上找到的所有内容都指向将该项目转换为尚未成熟的Android Studio。我想推迟迁移到Android Studio,直到Google宣称安全用于Google的生产使用。

Now here comes my question: How can I get started using Gradle for building while sticking to Eclipse? All the reads I found online point to converting the project to the still immature Android Studio. I'd like to put off migrating to Android Studio until that's declared "safe" for production use by Google.

理想情况下,我想要挂钩将脚本构建到Eclipse的调试和运行配置,与XCode中可以选择和选择不同的构建目标进行调试和归档非常相似。如果可能的话,需要采取哪些步骤才能完成这项工作?

Ideally, I'd like to be able to hook the build script(s) to the Debug and Run Configurations of Eclipse, very much the same way as I can pick and choose different build targets for debugging and archiving in XCode. If that's possible, what steps are required to make that work?

我对这些问题的质朴表示歉意,但对我而言,这实际上是一个未被发现的国家。任何帮助都不胜感激。

I apologize for the noobish quality of these questions, but for me this is actually quite an undiscovered country. Any help is appreciated.

编辑:
我们的团队已经在2013年10月底迁移到Android Studio,遇到越来越少的错误。如果您的组织对于采用1.0之前的开发环境不是很保守,我建议您进入冷水,并尝试使用Android Studio及其Gradle构建系统。缺少IMHO的唯一重要的事情是对单元测试的体面支持。

Our team has migrated to Android Studio in late October 2013 and since version 0.4 were are encountering fewer and fewer bugs. If your organization is not super-conservative about adopting pre-1.0 environments for development, I'd encourage you to jump into the cold water and try working with Android Studio and its Gradle build system. The only important thing missing IMHO is decent support for unit-testing.

推荐答案

可以使用2个构建系统(Eclipse +基于毕业生)。只需确保输出文件夹是不同的( bin for ADT, build for gradle)。
(TL的更新; DR:检查 Eclipse的Nodeclipse / Enide Gradle
市场))

It is possible to use 2 build systems (Eclipse + gradle based). Just make sure output folders are different (bin for ADT, build for gradle). (Update for TL;DR : check Nodeclipse/Enide Gradle for Eclipse (marketplace) )

文件 - >导出 - >生成Gradle构建文件将只添加 build.gradle ,其中包含以下内容(但检查版本)。没有现有的文件被更改。

File -> Export -> Generate Gradle build files will just add build.gradle with content below (but check versions). No existing files are changed.

com.android.tools.build:gradle 版本应该是最新的
对于渐变类型 gradle build http://tools.android.com/tech-docs/new-build-system/user-guide 。尝试毕业生任务了解更多。 (在我慢的互联网连接上,花了1个小时!毕业生下载所有需要的依赖项)

com.android.tools.build:gradle version should be the latest. For gradle type gradle build as said in http://tools.android.com/tech-docs/new-build-system/user-guide. Try gradle tasks for more. (On my slow Internet connection it took 1 hour! for gradle to download all needed dependencies)

Vogella教程 http://www.vogella.com/articles/AndroidBuild/article.html 尚未准备好。其他在线教程未完成 http: //www.jayway.com/2013/02/26/using-gradle-for-building-android-applications/

Vogella tutorial http://www.vogella.com/articles/AndroidBuild/article.html is not yet ready. Other online tutorials are not really finished http://www.jayway.com/2013/02/26/using-gradle-for-building-android-applications/

Eclipse ADT尚未使用毕业生,我认为它将在Android Studio中抛光。同时在两个IDE中开始使用不断发展的技术并不是很明智。

Eclipse ADT is not yet using gradle, I think it will be polished within Android Studio first. It would be not so wise to start using evolving technology in both IDEs at the same time.

请参阅 build.gradle 下面的例子。如果你已经掌握了毕业生,那么也许不需要奇才。
对于经典Android项目检查的最新 build.gradle 模板检查 gh.c / N / n-1 / b / m / oneeg / docs / android / build.gradle

See build.gradle example below. If you already mastered gradle, then maybe Wizards is not needed at all. For the latest build.gradle template for classic Android project check gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 8
    buildToolsVersion "19.0.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

ADT-Bundle不附带Eclipse Marketplace,因此可以使用更新站点。

ADT-Bundle does not come with Eclipse Marketplace, so update site could be used.

更新用于 Eclipse的Gradle Integration 的p2存储库

http://dist.springsource.com/release/TOOLS/gradle

但是从版本3.4.0起,它不提供.gradle文件的编辑器。
所以没有任何意义可以进行Android开发。

But as of version 3.4.0 it does not provide Editor for .gradle files. So there is no sense of having it for Android development.

我将使用默认的ADT构建,具有毕业作为实验的辅助构建
并在 http://tools.android.com上的错误流程时留意/ tech-docs / new-build-system 变得稀少。 (这应该是正式1.0版本)

I would go with default ADT build, having gradle as secondary build for experimentations and keeping an eye when flow of bugs on http://tools.android.com/tech-docs/new-build-system becomes rare. (That should be around formal 1.0 version)

更新:2014-04-15

UPDATE: 2014-04-15

Alex Ruiz(来自Android团队)关于Android,Gradle& ADT


Android的Gradle模型



而不是创建IDE-特定的Android / Gradle模型,我们决定与Gradle项目进行IDE无关的表示。这样,我们有一个更容易维护的单一信息来源。 IDE集成将被实现为每个支持的IDE(在我们的例子中是Eclipse和IDEA)的插件。这种方法的主要优点是可以独立于IDE集成插件释放Gradle插件。例如,我们可以发布一个新版本的Eclipse插件,它具有几个错误修复,而不影响Android的Gradle端。

Android’s Gradle Model

Instead of creating IDE-specific Android/Gradle models, we decided to have an IDE-agnostic representation of a Gradle project. This way, we have a single source of information that is easier to maintain. IDE integration will be implemented as a plug-in for each supported IDE (in our case, Eclipse and IDEA.) The main benefit of this approach is that we can release the Gradle plug-in independently of the IDE integration plug-ins. For example, we can ship a new version of the Eclipse plug-in that has several bug fixes, without affecting the Gradle side of Android.

截至2014年4月,eclipse-gradle插件与android-gradle插件不兼容:

As of April 2014 eclipse-gradle plugin is not compatible with android-gradle plugin:

正如问题57668 由Android团队(由@arcone提出)

As answered in Issue 57668 by Android team (raised by @arcone)


项目会员#2 x ... @ android.com

Project Member #2 x...@android.com

eclipse插件与Android插件不兼容。

The eclipse plugin is not compatible with the android plugin.

您将无法使用Eclipse中的默认Gradle支持将Android gradle项目导入到Eclipse中。

You will not be able to import an Android gradle project into Eclipse using the default Gradle support in Eclipse.

在Eclipse中工作,我们将不得不更改Eclipse的Gradle插件,我们正在修改IntelliJ中的Gradle支持相同的方式

To make it work in Eclipse we will have to change the Gradle plugin for Eclipse, the same way we are modifying the Gradle support in IntelliJ

那就是Android团队正在为IntelliJ和gra开发毕业插件Eclipse的dle插件需要更新。

That is Android team is working on gradle plugin for IntelliJ and gradle plugin for Eclipse needs to be updated too.

努力在Nodeclipse 平滑过渡时间。并继续在Eclipse中开发,同时还在尝试或充分利用毕业生。

There is effort at Nodeclipse to smooth the transition times. And continue to develop in Eclipse while still experimenting or fully using gradle.

Eclipse的Nodeclipse / Enide Gradle
市场

用于Eclipse的Gradle的一些屏幕截图:

Some screenshots for Gradle for Eclipse:

这篇关于是否可以使用Eclipse与Eclipse的Gradle构建系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆