错误:(23, 17) 无法解决:junit:junit:4.12 [英] Error:(23, 17) Failed to resolve: junit:junit:4.12

查看:52
本文介绍了错误:(23, 17) 无法解决:junit:junit:4.12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Why is it that every time I create a new project in Android Studio, it always comes up with:

错误:(23, 17) 无法解析:junit:junit:4.12?

Error:(23, 17) Failed to resolve: junit:junit:4.12?

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

When I remove testCompile 'junit:junit:4.12' in dependencies it is not a problem anymore.

build.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'
}

推荐答案

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

I had the same problem. Solved by adding url for missing repository in the build.gradle file:

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

就是这样.

这篇关于错误:(23, 17) 无法解决:junit:junit:4.12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆