【问题标题】:Cannot add compile 'com.android.support:design:27.0.2' to The Build Gradle无法将 compile 'com.android.support:design:27.0.2' 添加到 Build Gradle
【发布时间】:2018-01-28 17:41:32
【问题描述】:

我收到此特定错误,我的 SDK 管理器说支持目录已安装。

`Error:(11, 0) Could not find method compile() for arguments [com.android.support:design:27.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Please install the Android Support Repository from the Android SDK Manager.
<a href="openAndroidSdkManager">Open Android SDK Manager</a>`

提前致谢!

【问题讨论】:

标签: android android-studio android-support-library bottom-sheet android-support-design


【解决方案1】:

您在错误的部分添加依赖项。
不要在buildscript 块中添加支持库,也不要在顶层添加它们文件。

repositories { 
        google() 
        jcenter() 
        maven { url "maven.google.com"; /i added this line } 
     } 
    dependencies { 
        classpath 'com.android.tools.build:gradle:3.0.1' 

        REMOVE THESE LINES !!!

        compile  'com.android.support:appcompat-v7:27.+' //i added this line 
        compile 'com.android.support:design:27.+' // i added this line This is the only place where changes are made
    }

【讨论】:

    【解决方案2】:

    将 27.0.2 替换为 27.+ 被认为是不好的做法。确保您在依赖项{} 块中的正确 Gradle 文件 app/build.gradle 中添加依赖项。

    【讨论】:

    • 谢谢.. 我正在针对错误的 sdk 版本进行编译!只需更改它即可解决问题!不过谢谢!
    • 是的,这通常是导致这些问题的原因。
    【解决方案3】:

    确保您在

    中添加依赖项

    project>app>build.gradle

    不在你的

    项目>build.gradle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-13
      • 2021-07-05
      • 2015-01-07
      • 1970-01-01
      相关资源
      最近更新 更多