Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error (23,17) Failed to resolve junit:junit: 4.12 @ Android Studio v.2

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

like image 919
Abdullah Al Hasan Avatar asked Apr 11 '16 08:04

Abdullah Al Hasan


3 Answers

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'

   ....

}
like image 159
Rohit Arya Avatar answered Oct 27 '22 22:10

Rohit Arya


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
like image 3
Kona Suresh Avatar answered Oct 27 '22 23:10

Kona Suresh


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.

like image 1
the_struggler Avatar answered Oct 27 '22 23:10

the_struggler