简体   繁体   English

Android,Gradle:通过buildType名称设置testBuildType

[英]Android, Gradle: Set testBuildType by buildType name

My build.gradle: 我的build.gradle:

android {
    testBuildType "stage"
     buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        prod {
            // This copies the debuggable attribute and debug signing configurations.
            initWith(debug)
        }
        stage {
            initWith(debug)
            // some code here
        }
        dev {
            initWith(debug)
            // some code here
        }
    }
}

As you can see I testBuildType as string. 如您所见,我将testBuildType作为字符串。 But I want set by buildType.name . 但是我想通过buildType.name设置。

Something like this: 像这样:

testBuildType buildType.stage

I get this error : 我收到此错误:

Error:(56, 0) Could not get unknown property 'stage' for BuildType container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.

Is it possible? 可能吗?

您需要将testBuildType元素放入buildTypes块中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM