Picking a specific build type in a dependency

后端 未结 5 2447
闹比i
闹比i 2021-02-20 07:14

Suppose I have an Android app with three build types:

buildTypes {
    release {
        ....
    }
    optRelease {
        ....
    }
    debug {
        ....
         


        
5条回答
  •  渐次进展
    2021-02-20 07:30

    What I did is :

    Created product flavors:

        android {
            flavorDimensions 'tier'
            compileSdkVersion 27
            defaultConfig {
                applicationId "com.example.sample"
                minSdkVersion 15
                targetSdkVersion 27
            }
    
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    --------------
                }
                debug {
                    debuggable true
                }
            }
            productFlavors {
                qc {
                    applicationIdSuffix ".qc"
                    dimension "tier"
    
                }
                production {
                    applicationIdSuffix ".production"
                    dimension "tier"
                }
            }
        }
    

    Allow dependencies to choose the build types like below

    dependencies { 
        qcDebugCompile project(path: ':libName', configuration: "debug") 
        qcReleaseCompile project(path: ':libName', configuration: "release") 
        productionDebugCompile project(path: ':libName', configuration: "debug") 
        productionReleaseCompile project(path: ':libName', configuration: "release") 
    ... 
    } 
    

提交回复
热议问题