Reputation: 307
I just installed Android Studios on my work computer and I created a new blank project. However, I receive the following error.
Failed to resolve: junit:junit:4.12
I have attempted numerous solutions from the previous time this question was asked but none of them seem to be working. I tried commenting out the entire line compile files('libs/junit-4.12.jar'). I tried copy pasting the jar file from the Android studio lib folder to my project lib folder and adding it as a library. On top of that,the gradle always takes more than 10 minutes to build. So any solution I want to try takes me a while. Please help.
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.example.mabbasi.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:24.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/junit-4.12.jar')
}
build.bradle(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.2.1'
// 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
}
Upvotes: 1
Views: 10823
Reputation: 75778
JUnit is a unit testing framework for Java programming language.
JUnit has been important in the development of test-driven development .
At first modify your build.gradle
from Project Level
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
At first remove compile files('libs/junit-4.12.jar')
from build.gradle
( Module Level) section .
Then Clean-Rebuild-Gradle-Run .
Upvotes: 3
Reputation: 9150
Try adding mavenCentral()
as a repository, and also remove compile files('libs/junit-4.12.jar')
buildscript {
...
repositories {
mavenCentral()
}
...
}
Upvotes: 0