android - Gradle 错误 : ProductFlavor names cannot start with 'test'

标签 android android-gradle-plugin

试图将我的 productFlavor 命名为“test”并收到错误:

 ERROR: ProductFlavor names cannot start with 'test'

从源代码中我看到了简单的检查:

 private void addBuildType(BuildType buildType) {
    if (buildType.name.startsWith("test")) {
        throw new RuntimeException("BuildType names cannot start with 'test'")
    }...
}

看来我可以使用“myTest”、“aTest”等名称,但不能使用“test1”、“test2”等。 这有什么可能的原因吗?谢谢。

最佳答案

正如您在这个 Google 中看到的 repository第93行

private void addBuildType(BuildType buildType) {
    if (buildType.name.startsWith("test")) {
        throw new RuntimeException("BuildType names cannot start with 'test'")
    }
    if (productFlavors.containsKey(buildType.name)) {
        throw new RuntimeException("BuildType names cannot collide with ProductFlavor names")
    }
    def sourceSet = project.sourceSets.add(buildType.name)
    BuildTypeData buildTypeData = new BuildTypeData(buildType, sourceSet, project)
    project.tasks.assemble.dependsOn buildTypeData.assembleTask
    buildTypes[buildType.name] = buildTypeData
}

所以 addBuildType 方法有它自己的不使用 test name 的异常(exception)。你不能用这个。以及他们为什么做出这个决定。除了谷歌,没有人能回答。

关于android - Gradle 错误 : ProductFlavor names cannot start with 'test' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54765759/

相关文章:

android-studio - 如何防止 rawproto 文件生成或自动删除它们?

android - 错误 : The Android Gradle plugin supports only Butterknife Gradle plugin version 9. 0.0-rc2 及更高版本

android - 如何每 5 分钟运行一个前台服务 10 秒?

Android Studio 不生成签名的 apk

java - 使用 Android Studio 未将外部 Jar 库包含到 apk 中

android - Android : Boolean in "1" or "0" 中的简单库

android - 在 Android Studio 中将 Build Type debuggable 设置为 True 不适用

android - 使用 setBinding 在 Android 项目的 settings.gradle 上导入库的问题

java - 使用 OData 时如何加速 Android 的 ReSTLet?

android - MobileFirst 7.1 加密缓存 ERROR_COULD_NOT_GENERATE_KEY