无法解决:junit:junit:4.12在android studio 1.4在ubuntu上

当我在ubuntu上的 android studio 1.4中创建新项目时.

当毕业生的同步完成时,我收到此错误

testCompile 'junit:junit:4.12'

在app / build.gradle上显示消息

Error:(23,17) Failed to resolve: junit:junit:4.12
Show in File
Show in Project Structure dialog

// build gradle(app module)

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsversion "23.0.1"

defaultConfig {
    applicationId "com.example.abhishek.vearch"
    minSdkVersion 16
    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'
compile 'com.android.support:design:23.0.1'
}

//建立毕业生(项目)

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'

    // 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
}

>我试过Error:(23,17) Failed to resolve: junit:junit:4.12

解决方法

有些人通过添加下面的块来解决存储库缺失的URL.
android {
    .....
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    .....
}

只需提到:右键单击“应用程序”文件夹,然后转到“打开模块设置”.然后移动到最后一个选项卡’依赖关系’,并通过搜索重新添加junit.我试图添加较早的版本,但未能使其正常工作.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...