试图将我的 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/