I created a new project after installing Android Studio 2.3.3 and then the Gradle build failed because of these three errors:
Error:Failed to resolve: junit:junit:4.12
Open File
Show in Project Structure dialog
Error:Failed to resolve: org.hamcrest:hamcrest-library:1.3
Open File
Show in Project Structure dialog
Error:Failed to resolve: org.hamcrest:hamcrest-integration:1.3
Open File
Show in Project Structure dialog
and I tried looking at similar questions and their answers but they didn't work for me. I tried deleting the testCompile line in gradle.build, and I tried adding the url maven "{ url 'http://repo1.maven.org/maven2' }" in the gradle.build file, and I checked the firewall and I downloaded the junit.jar and nothing worked.
Edit:
build.gradle (module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.tasneem.sunshine"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}