Add dependency to specific productFlavor and buildType in gradle

前端 未结 6 1772
长情又很酷
长情又很酷 2020-12-05 11:31

I\'m wondering how to add dependency to specific productFlavor and buildType in gradle. For example I have productFlavor free and build type release

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 12:13

    These task are generated dynamically based on your Android plugin configuration. At the time of configuration they are not available to you yet. You can defer the creation of your task in two ways:

    Wait until the project is evaluated.

    afterEvaluate {
        task yourTask(dependsOn: assembleFreeRelease) {
            println "Your task"
        }
    }
    

    Lazily declaring the task dependency as String.

    task yourTask(dependsOn: 'assembleFreeRelease') {
        println "Your task"
    }
    

提交回复
热议问题