- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个应用需要为不同的客户使用不同的资源多次构建(品牌、配置和客户之间的预加载数据更改)。
在今年的 Google I/O 之后,我听说了新的基于 Gradle 的 Android 构建系统。所以我认为,使用 Gradle 构建脚本来实现这种单源/多 apk 场景是个好主意。
现在我的问题来了:如何在坚持使用 Eclipse 的同时开始使用 Gradle 进行构建?我在网上找到的所有读物都指向将项目转换为仍然不成熟的 Android Studio。我想推迟迁移到 Android Studio,直到它被 Google 宣布为“安全”以供生产使用。
理想情况下,我希望能够将构建脚本与 Eclipse 的调试和运行配置 Hook ,这与我可以选择不同的构建目标以在 XCode 中进行调试和归档非常相似。如果可以的话,需要哪些步骤才能实现?
我为这些问题的无聊性质道歉,但对我来说,这实际上是一个未被发现的国家。任何帮助表示赞赏。
编辑:我们的团队已于 2013 年 10 月下旬迁移到 Android Studio,并且自 0.4 版以来遇到的错误越来越少。如果您的组织对采用 1.0 之前的环境进行开发不是非常保守,我鼓励您跳入冷水并尝试使用 Android Studio 及其 Gradle 构建系统。恕我直言,唯一重要的事情是对单元测试的体面支持。
最佳答案
可以使用 2 个构建系统(基于 Eclipse + gradle)。只需确保输出文件夹不同(bin
用于 ADT,build
用于 gradle)。(TL 更新;DR:检查 Nodeclipse/Enide Gradle for Eclipse(marketplace))
File -> Export -> Generate Gradle build files
只会添加 build.gradle
内容如下(但检查版本)。没有更改任何现有文件。
com.android.tools.build:gradle
版本应为 the latest .对于 gradle 类型 gradle build
如 http://tools.android.com/tech-docs/new-build-system/user-guide 中所述.尝试 gradle tasks
了解更多信息。 (在我缓慢的 Internet 连接上,需要 1 小时!gradle 下载所有需要的依赖项)
Vogella 教程 http://www.vogella.com/articles/AndroidBuild/article.html还没有准备好。其他网上教程还真没看完http://www.jayway.com/2013/02/26/using-gradle-for-building-android-applications/
Eclipse ADT 还没有使用 gradle,我认为它会首先在 Android Studio 中完善。在两个 IDE 中同时开始使用不断发展的技术是不明智的。
请参阅下面的 build.gradle
示例。如果你已经掌握了 gradle,那么可能根本不需要 Wizards。有关经典 Android 项目的最新 build.gradle
模板,请查看 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,因此可以使用更新站点。
更新 Gradle Integration for Eclipse 的 p2 存储库是
http://dist.springsource.com/release/TOOLS/gradle
但从 3.4.0 版开始,它不提供 .gradle 文件的编辑器。所以在 Android 开发中使用它是没有意义的。
我会使用默认的 ADT 构建,将 gradle 作为实验的辅助构建并密切关注 http://tools.android.com/tech-docs/new-build-system 上的错误流变得罕见。 (那应该是正式的1.0版本左右)
更新:2014-04-15
Alex Ruiz's (from Android team) Blog about Android, Gradle & ADT
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 插件不兼容:
正如 Issue 57668 中的回答由 Android 团队(由@arcone 提出)
Project Member #2 x...@android.com
The eclipse plugin is not compatible with the android plugin.
You will not be able to import an Android gradle project into Eclipse using the default Gradle support in Eclipse.
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 的 gradle 插件,Eclipse 的 gradle 插件也需要更新。
有effort at Nodeclipse平滑过渡时间。并继续在 Eclipse 中进行开发,同时仍在试验或完全使用 gradle。
Nodeclipse/Enide Gradle for Eclipse(marketplace)
Gradle for Eclipse 的一些截图:
关于android - 是否可以在 Eclipse 中使用适用于 Android 的 Gradle 构建系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17107014/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!