Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve junit:junit:4.12

I am using Android studio 2.2 and I am trying to compile the sample android application given in the get started section of developer.android.com. When I build the application I get the following error.

Could not resolve junit:junit:4.12. Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'. Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'. Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection timed out: connect

I have gone through a number of threads in stackoverflow.com related to this error. I did the following as suggested in these threads, but my problem is not resolved.

Step 1

Updated buildgrid{} section of build.gradle (application) with this:

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

Step 2

Updated android{} section of build.gradle (module) with this:

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

I have also configured manual proxy with a proper proxy server IP and I could also test the connection successuflly to URL https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom. I have also pasted this URL in a web browser, which downloads the junit-4.12.pom successfully. What I am not able to understand is, when connection to the above URL is successful, why the build fails?

like image 842
KurioZ7 Avatar asked Oct 20 '16 03:10

KurioZ7


2 Answers

Add below repository in your build.gradle file,

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
    jcenter { url "http://jcenter.bintray.com/" }
}
like image 94
Sekhar Madhiyazhagan Avatar answered Sep 27 '22 02:09

Sekhar Madhiyazhagan


I had this problem today. For me it was a proxy settings issue.

I opened the file 'gradle.properties' in my project and added the following settings. Then everything synchronized and downloaded for me.

systemProp.http.proxyHost=XX.XX.XX.XX
systemProp.http.proxyPort=80

systemProp.https.proxyHost=XX.XX.XX.XX
systemProp.https.proxyPort=80
like image 33
Aaron G Avatar answered Sep 26 '22 02:09

Aaron G