Picking a specific build type in a dependency

后端 未结 5 2340
闹比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:52

    If you want to add a dependency for a variant that combines a product flavor and a build type, then you must initialize the configuration name in the configurations block.(如果想为自定义的buildTypes来添加dependencies,需要配置configurations {})

    android {
        buildTypes {
            release {
                ....
            }
            optRelease {
                ....
            }
            debug {
                ....
            }
        }
    }
    
    configurations {
        // Initializes a placeholder for the optReleaseImplementation dependency configuration
        optReleaseImplementation {}
    }
    
    dependencies {
            debugImplementation xxx
            // Then it can work
            optReleaseImplementation xxx
            releaseImplementation xxx
        }
    

提交回复
热议问题