java 错误 (23,17) 无法解析 junit:junit: 4.12 @ Android Studio v.2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36543440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error (23,17) Failed to resolve junit:junit: 4.12 @ Android Studio v.2
提问by Abdullah Al Hasan
Currently using Android studio v.2.0 when first time application opened. It showed Error
第一次打开应用程序时,当前使用的是 Android Studio v.2.0。它显示错误
(23,17) Failed to resolve junit:junit: 4.12
(23,17) Failed to resolve junit:junit: 4.12
I have installed Android Support Repository, support repository
我已经安装了 Android Support Repository, support repository
My Gradle code in the picture.Android Studio V.2.0
图中我的 Gradle 代码。安卓工作室 V.2.0
回答by Rohit Arya
You should add this in your build.gradle
(because junit
is pulled from maven repository):
您应该将其添加到您的build.gradle
(因为junit
是从 maven 存储库中提取的):
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
....
}
回答by Kona Suresh
If any Junit test or InstrumentationTest issues you should follow like this
如果任何 Junit 测试或 InstrumentationTest 问题,你应该像这样
just copy these lines into the app gradle file.
只需将这些行复制到应用程序 gradle 文件中即可。
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
And If your system under the proxy you should provide the proxy username and password.
如果您的系统在代理下,您应该提供代理用户名和密码。
The "gradle.properties" file having the http values only, so we should provide https values also. Then it resolves the any https request from your project.
“gradle.properties”文件只有 http 值,所以我们也应该提供 https 值。然后它解析来自您的项目的任何 https 请求。
systemProp.http.proxyPassword=Computer@8899
systemProp.http.proxyHost=182.89.7.11
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyUser=suresh.kona
systemProp.http.proxyPort=80
systemProp.https.proxyPassword=Computer@8899
systemProp.https.proxyHost=182.89.7.11
systemProp.https.proxyUser=suresh.kona
systemProp.https.proxyPort=80
回答by Oliver Rajiv Suzuki
I realise this is an old question, but i just encountered the same issue.
我意识到这是一个老问题,但我刚刚遇到了同样的问题。
In my particular case it was the firewall causing it. Make sure android studio is whitelisted in your firewall solution.
在我的特殊情况下,它是防火墙引起的。确保 android studio 在您的防火墙解决方案中被列入白名单。