studio3.1.1关于Error:Unable to resolve dependency 的解决方案

上课的时候死活解决不了,然后老师过来帮我一鼓捣就好了。。。记下来老师的解决方法,便于以后再出错自己自行解决

我的错误:

Possible causes:<ul><li>The project ‘XXXXXXX' may be using a version of Gradle that does not containPossible causes:<ul><li>The project ‘XXXXXXX' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The <a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

 the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

 

或者类似这样的错误,我之前的解决方法是,复制一份之前的gradle的dependencies

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}


但是recyclerview始终报错。。

老师说我出现问题的原因是下载了新的Android Studio后因为被墙没有下成功对应的gradle。。

解决方法就是科学上网以后,打开settings,搜索HTTP proxy


将此时HTTP(S)代理服务器的码填入Host nameport number中,再build一下,等到编译成功后再切换到no proxy就好