Error:(23, 17) Failed to Resolve: Junit:Junit:4.12

Failed to resolve : Error:(23, 17) junit:junit:4.12 in android studio 1.4

If you are adding them to buildscript you will get an error.

It is a difference between the buildscript repository and the repositories for the dependencies. The buildscript is used for gradle build dependencies.

You will need to add the following to your build.gradle file and it should work fine.

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

Following should work:

apply plugin: 'com.android.application'

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

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.example.application"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}

Could not resolve junit:junit:4.12

Add below repository in your build.gradle file,

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

I have an error in Android studio Failed to resolve junit:4.12

I figured out a way to fix this. this is not a solution to the error but it will help you run the project if you have the same errors as me and no other method worked. I downloaded a new gradle and extracted it to C:/Users/Username/gradle/wrapper/dist folder then changed the gradle in Android studio from file->settings
I also commented the whole testCompile block in the gradle (module) file and removed junit4.12 from the module settings of the project.
This seemed to fix the problem and I could run the project on my Android device.

Failed to resolve: org.junit:junit:4.12 with AndroidX Test JUnit

The above issue has been fixed in 1.0.0-beta02

'androidTestImplementation "androidx.test.ext:junit:1.0.0-beta02'



Related Topics



Leave a reply



Submit