android - assembleDebug.dependsOn 不工作

标签 android android-gradle-plugin

首先:这不是这个的副本

Error:Could not find property 'assembleDebug' on project ':app'

问题:

自从更新到 Android Studio 2.2(gradle 插件 2.2)后,您不能再通过这种方式使任务 assembleDebugassembleRelease 依赖于新任务:

assembleDebug.dependsOn 'checkstyle'

issue 中有更多详细信息

它给你以下错误:

Error:Could not get unknown property 'assembleDebug' for project ':app' of type org.gradle.api.Project.

最佳答案

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

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

更新

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

    afterEvaluate {
        assembleDebug.dependsOn someTask
 }

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

关于android - assembleDebug.dependsOn 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39642141/

相关文章:

android - 如何在android studio中用内部模块替换外部库依赖项

android - 如何在点击时滚动水平回收 View ?

android - 我怎样才能用科学记数法将 double 舍入到 TextView 中?

android - 找不到 com.android.tools :common:25. 2.3

android - 多次调用 Gradle buildConfig

android - Flutter:在根项目 'assembleStageDebug' 中找不到任务 'android'

android - FragmentPagerAdapter 滑动显示 ListView 1/3 屏幕宽度

android - 如何在整个应用程序中定期检查 Internet 连接?

android - 找不到名称为 'default' 的配置。安卓工作室

android - android中的gradle依赖错误