本文介绍了assembleDebug.dependsOn不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:这不是此内容的重复

First of all: This is not a duplicate of this

错误:在项目':app'上找不到属性'assembleDebug'

问题:

自从更新Android Studio 2.2(Gradle插件2.2)以来,您不能再通过以下方式使任务assembleDebugassembleRelease依赖于新任务:

Since the update to Android Studio 2.2 (gradle plugin 2.2) You can no longer make the task assembleDebug or assembleRelease to be dependent on a new task in this way:

assembleDebug.dependsOn 'checkstyle'

问题

它给您以下错误:

推荐答案

一种替代方法是通过以下方式引用任务:

An alternative is to refer to the task in the following way:

tasks.whenTaskAdded { task ->
    if (task.name == 'assembleDebug') {
        task.dependsOn 'checkstyle'
    }
}

更新

Android任务通常是在"afterEvaluate"阶段创建的.从2.2开始,这些任务还包括"assembleDebug"和"assembleRelease".要访问此类任务,用户将需要使用afterEvaluate闭包:

Android tasks are typically created in the "afterEvaluate" phase. Starting from 2.2, those tasks also include "assembleDebug" and "assembleRelease". To access such tasks, the user will need to use an afterEvaluate closure:

    afterEvaluate {
        assembleDebug.dependsOn someTask
 }

来源: https://code.google.com/p/android/issues/detail?id = 219732#c32

这篇关于assembleDebug.dependsOn不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 17:59