错误:(23、17)无法解决:junit:junit:4.12

新手上路,请多包涵

为什么每次我在 Android Studio 中创建一个新项目时,总是出现:

错误:(23、17)无法解决:junit:junit:4.12?

当我在依赖项中删除 testCompile 'junit:junit:4.12' 时,它不再是问题了。

构建.gradle

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.okedroid.myapplication"
        minSdkVersion 17
        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'
}

原文由 fathurzero 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 608
1 个回答

我有同样的问题。通过在 build.gradle 文件中添加缺少存储库的 url 来解决:

 android {
    [...]
    repositories {
        maven { url 'https://repo1.maven.org/maven2' }
    }
    [...]
}

而已。

原文由 mdew 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题