【问题标题】:Android Studio - Build fails on compile, cannot find dsl.dependencies.DefaultDependencyHandlerAndroid Studio - 编译时构建失败,找不到 dsl.dependencies.DefaultDependencyHandler
【发布时间】:2026-02-24 09:45:01
【问题描述】:

这里是 build.gradle:

C:\Users\billb\StudioProjects\ShoppingList03>type build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath "/com.android.tools.build.gradle:3.3/"
        compile "com.android.support:support-core-utils:26.1.0"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

编译时出错:找不到 DefaultDependencyHandler。 我已经重新加载了 Android SDK Platform-Tools 和 SDK Tools,都是 26.0.1

这个 DefaultDependencyHandler 在哪里?为什么需要它?
显然,我的 android java 代码中有一些东西需要这个。

有什么想法吗?我花了太多时间试图追查此事。

【问题讨论】:

    标签: android android-studio android-gradle-plugin android-studio-3.0


    【解决方案1】:

    app 级别的build.gradle 文件中添加compile "com.android.support:support-core-utils:26.1.0" 行,而不是project 级别的build.gradle 文件。

    【讨论】: