无法解决:android studio中的com.android.support:design:27

时间:2018-02-21 05:13:50

标签: java android

我在android studio中遇到了这两个错误。如何解决此错误。

Error:(27, 13) Failed to resolve: com.android.support:design:27.+
    <a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:D:/android project/My` `Projects/MyApplication2/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:27.+
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:D:/android project/My Projects/MyApplication2/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

这是我的依赖代码

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:27.+'
    compile 'com.android.support:design:27.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

如何解决此错误

1 个答案:

答案 0 :(得分:0)

&lt; p&gt;要从版本26.0.0开始使用支持库,您需要将Google的Maven存储库添加到项目的build.gradle文件中。&lt; / p&gt; &LT;醇&GT; &lt; li&gt;打开应用程序的build.gradle文件。&lt; / li&gt; &lt; li&gt;确保存储库部分包含带有的maven部分 “&lt; a href =”https://maven.google.com“rel =”nofollow noreferrer“&gt; https://maven.google.com< / a&gt;”端点。例如:&lt; / li&gt; &LT; /醇&GT; &LT; p为H.例如:&lt; / p为H. &lt; pre&gt;&lt; code&gt; allprojects {     存储库{         jcenter()         maven {             网址“https://maven.google.com”         }     } } &LT; /代码&GT;&LT; /预&GT; &lt; p&gt;对于Android Studio 3.0.0及更高版本:&lt; / p&gt; &lt; pre&gt;&lt; code&gt; allprojects {     存储库{         jcenter()         谷歌()     } } &LT; /代码&GT;&LT; /预&GT;