Error:(23, 17) Failed to resolve: junit:junit:4.12
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.
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 meandroidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations'}) //if available, also delete these two linescompile '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.
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