Android Studio错误 Failed to resolve: junit:junit:4.12解决方案

遇到这个问题的时候百度了很久,看来很多篇博客,里面讲到的无非两种方法

1.删除或者注释掉module: app的build.gradle中下列语句,并点击“try again”, 

testCompile 'junit:junit:4.12'

我的build.gradle里还需要把

  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       exclude group: 'com.android.support', module: 'support-annotations'
    })

这部分注释掉

2.在Project: 项目名 这个文件中添加

allprojects {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

上面两种方法我都试过,特别是第二种试了很久,可项目还是无法运行,但第一种是可以的,但有人说第一种是一种掩耳盗铃的做法,并没有实际解决问题,这就很纠结了,不管怎么说吧,解决了就是好方法,谁叫我们是凡人呢

猜你喜欢

转载自blog.csdn.net/dreamjay1997/article/details/81088068