我正在使用 Android Developer Tools 22、Eclipse Indigo 和当前适用于 Eclipse 的 Gradle 插件。
现在我想通过在 build.gradle 文件中定义来使用不同的 Flavor:
productFlavors{
A {
packageName "com.test.A"
buildConfig "public final static String FLAVOR = \"A\";"
}
B {
packageName "com.test.B"
buildConfig "public final static String FLAVOR = \"B\";"
}
}
据我所知,我可以使用 BuildConfig.FLAVOR 访问这些变量,但是在 gen 文件夹中生成的 BuildConfig.java 中缺少 FLAVOR 的定义。
如果我通过 Gradle 组装我的项目,则会在文件夹 build/source/buildConfig/[A|B]/[debug|release]/com/test/中生成正确且完整的 BuildConfig.java >.
如果我通过 gradle 构建项目,它可以工作,但我不能使用 Eclipse,因为它期望变量是在 gen 文件夹中的 BuildConfig.java 中定义的
我可以强制 gradle 或 adt 在 gen 文件夹中生成正确的 BuildConfig.java 吗?
最佳答案
Android Studio 处于最前沿(尚未测试版)。
正如 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 插件也需要更新。
您可以在 Eclipse 中使用 ADT 进行开发,并使用 Nodeclipse/Enide Gradle for Eclipse 运行 Gradle 构建。 (marketplace)
Gradle for Eclipse: 的一些截图
关于android - ADT Eclipse + Gradle : incomplete BuildConfig. java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17340455/