When i am creating new project in android studio 1.4 on ubuntu.
I am getting this error when gradle's sync completed on
testCompile 'junit:junit:4.12'
with message on app/build.gradle
Error:(23, 17) Failed to resolve: junit:junit:4.12
Show in File
Show in Project Structure dialog
// build gradle (app module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.abhishek.vearch"
minSdkVersion 16
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.0.1'
compile 'com.android.support:design:23.0.1'
}
// 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:1.3.0'
// 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
}
Some people have solved by adding below block for missing URL for repository.
android {
.....
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
.....
}
Just to mention : Right click on 'app' folder and goto 'Open Module Settings'. Then move to last tab 'Dependencies' and re-add junit by searching. I tried to add earlier versions but failed to get it working.
if you're using open JDK 8 it could be because of a bug with the cacerts. Maybe you could try the following to fix the broken cacerts:
$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java
I tried changing my jcenter() to the one with the url as well as trying to change it to maven { url ... } and both didn't work. This one fixed it for me.
See: https://stackoverflow.com/a/33440168
In my case I was behind a proxy and the issue has been resolved using both
jcenter {
url "http://jcenter.bintray.com/"
}
and
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With