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
When to Use Generic Methods and When to Use Wild-Card
How to Change a Jfreechart'S Size
How to List Target Platforms. Please Make Sure the Android Sdk Path Is Correct
Any Good Orm Tools for Android Development
Service Discovery Failed Exception Using Bluetooth on Android
Read_External_Storage Permission for Android
Wait Until Tomcat Finishes Starting Up
How to Run Sudo Command Without Password from Java Program
Why Parallel Execution on Java Compile Take Linear Growth in Time
How to Implement Basic Authentication with Glassfish
How to Cast a List of Supertypes to a List of Subtypes
Difference Between Dto, Vo, Pojo, Javabeans
When Exactly Is It Leak Safe to Use (Anonymous) Inner Classes
How to Check If an App Running on Android
How to Get Android Wifi Scan Results into a List
How to Delete Firebase Data After "N" Days