You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中无法添加Material Design 1的问题求助

解决方案

错误一修复:依赖配置位置错误

根项目的build.gradle(项目级)无法使用implementation依赖配置,因为该配置属于模块级构建脚本(如app/build.gradle)的范畴。根项目仅用于全局插件的统一配置,不处理具体模块的依赖声明。

修改步骤:

  1. 打开模块级的build.gradle(路径:app/build.gradle)
  2. 在该文件的dependencies块中添加Material Design依赖:
dependencies {
    // 保留原有其他依赖
    implementation 'com.google.android.material:material:1.4.0'
}
  1. 删除根项目build.gradle中的dependencies块。

错误二修复:仓库配置位置错误

Android Studio Dolphin对应的Gradle 7.x+版本要求仓库配置放在settings.gradle中,而非根项目的build.gradle,否则会触发仓库优先级冲突的错误。

修改步骤:

  1. 打开settings.gradle文件
  2. 在dependencyResolutionManagement块中配置仓库(无此块则直接添加):
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
  1. 删除根项目build.gradle中的repositories块。

最终根项目build.gradle内容

修改后,根项目的build.gradle应简化为:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

完成以上修改后,同步Gradle项目即可解决两个错误。

内容的提问来源于stack exchange,提问作者Laplace

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 13:25:17