我刚刚在我的工作计算机上安装了 Android Studios,并创建了一个新的空白项目。但是,我收到以下错误。
解析失败:junit:junit:4.12
从上次被问到这个问题开始,我尝试了很多解决方案,但似乎没有一个有效。我尝试注释掉整行 compile files('libs/junit-4.12.jar')。我尝试将 jar 文件从 Android Studio lib 文件夹复制粘贴到我的项目 lib 文件夹并将其添加为库。最重要的是,gradle 总是需要超过 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(项目)
// 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
}
最佳答案
JUnit 是 Java 编程语言的单元测试框架。
JUnit has been important in the development of test-driven development .
首先从项目级别修改你的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
}
重复
首先从 build.gradle
( Module Level) 部分删除 compile files('libs/junit-4.12.jar')
。
然后Clean-Rebuild-Gradle-Run。
关于android - 无法解析 : junit:junit:4. 12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40029657/