KurioZ7 KurioZ7 - 1 month ago 28
Android Question

Could not resolve junit:junit:4.12

I am using Abdroid 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?

MSS MSS
Answer

Add below repository in your build.gradle file,

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
    jcenter { url "http://jcenter.bintray.com/" }
}
Comments