我刚刚在我的工作电脑上安装了Android工作室,我创建了一个新的空白项目。但是,我收到以下错误。
未能解决: junit:junit:4.12
从上一次提出这个问题以来,我曾尝试过许多解决办法,但似乎没有一种解决办法奏效。我试着注释掉整个编译文件(‘libs/junit-4.12.jar’)。我尝试将jar文件从文件夹粘贴到我的项目库文件夹中,并将其添加为一个库。最重要的是,压舱的建造时间总是超过10分钟。所以我想尝试的任何解决方案都需要我一段时间。请帮帮忙。
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
}发布于 2016-10-14 05:24:58
JUnit是一个面向Java编程语言的单元测试框架。
JUnit在开发测试驱动的开发中一直很重要。
首先从项目级别修改您的build.gradle
// 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
}复制
首先,将compile files('libs/junit-4.12.jar')从build.gradle (模块级)部分中删除。
然后是Clean-Rebuild-Gradle-Run。
发布于 2016-10-13 20:49:30
尝试将mavenCentral()添加为存储库,并删除compile files('libs/junit-4.12.jar')
buildscript {
...
repositories {
mavenCentral()
}
...
}https://stackoverflow.com/questions/40029657
复制相似问题