Error:(23, 17) Failed to resolve: junit:junit:4.12
Solution 1:
I had the same problem. Solved by adding url for missing repository in the build.gradle
file:
android {
[...]
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
[...]
}
That's it.
Solution 2:
Just remove the "testCompile 'junit:junit:4.12'" from build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'//remove this line and sync again... worked for me
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'}) //if available, also delete these two lines
compile 'com.android.support:appcompat-v7:23.0.1'
}
worked for me and I am Happy! :)
Remember that this is not the actual answer of this question. I mentioned this because it works when you remove above lines.
Solution 3:
Go to File -> Project Structure. Following window will open:
From there:
- remove the junit library (select junit and press "-" button below ) and
- add it again (select "+" button below, select "library dep.", search for "junit", press OK ). Press OK to apply changes. After around 30 seconds your gradle sync should work fine.
Hope it works for you too :D
Solution 4:
It's not able to get junit library.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
After adding above line inside android block in build.gradle file, it resolved problem. This can be because your Android studio doesn't have junit library.
Solution 5:
add repository in your build.gradle file
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}