Skip to content Skip to sidebar Skip to footer

Failed To Resolve : Junit:junit:4.12 In Android Studio 1.4 On Ubuntu

When i am creating new project in android studio 1.4 on ubuntu. I am getting this error when gradle's sync completed on testCompile 'junit:junit:4.12' with message on app/build.

Solution 1:

Some people have solved by adding below block for missing URL for repository.

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

Just to mention : Right click on 'app' folder and goto 'Open Module Settings'. Then move to last tab 'Dependencies' and re-add junit by searching. I tried to add earlier versions but failed to get it working.

Solution 2:

if you're using open JDK 8 it could be because of a bug with the cacerts. Maybe you could try the following to fix the broken cacerts:

$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java

I tried changing my jcenter() to the one with the url as well as trying to change it to maven { url ... } and both didn't work. This one fixed it for me.

See: https://stackoverflow.com/a/33440168

Solution 3:

In my case I was behind a proxy and the issue has been resolved using both

jcenter {
    url "http://jcenter.bintray.com/"
}

and

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

Solution 4:

If you are facing issue with junit:junit4.12. This is the solution.

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

Add these above two line after

apply plugin: 'com.android.application'

Solution 5:

//remove this line- testCompile 'junit:junit:4.12'

and sync again... worked for me-

dependencies 

{

compile fileTree(dir: 'libs', include: ['*.jar'])

testCompile 'junit:junit:4.12'   //remove this line from here

compile'com.android.support:appcompat-v7:23.0.1'

}

Post a Comment for "Failed To Resolve : Junit:junit:4.12 In Android Studio 1.4 On Ubuntu"