6
votes

Currently using Android studio v.2.0 when first time application opened. It showed Error

(23,17) Failed to resolve junit:junit: 4.12

I have installed Android Support Repository, support repository

My Gradle code in the picture.Android Studio V.2.0

3
simply remove this line: testCompile 'junit:junit:4.12' - Luca Ziegler

3 Answers

6
votes

You should add this in your build.gradle (because junit is pulled from maven repository):

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'

   ....

}
3
votes

If any Junit test or InstrumentationTest issues you should follow like this

just copy these lines into the app gradle file.

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.

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
1
votes

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.