无法解析:JUnit的:JUnit的:4.12在Ubuntu的机器人工作室1.4

无法解析:JUnit的:JUnit的:4.12在Ubuntu的机器人工作室1.4

问题描述:

在我创建在Ubuntu的机器人工作室1.4新项目。

When i am creating new project in android studio 1.4 on ubuntu.

我收到此错误时,摇篮的同步完成了

I am getting this error when gradle's sync completed on

testCompile 'junit:junit:4.12' 

与应用程序/ build.gradle消息

with message on 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'
}

//建立摇篮(项目)

// build gradle (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: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)无法解析:JUnit的:JUnit的:4.12
    • I have tried Error:(23, 17) Failed to resolve: junit:junit:4.12

有些人通过添加以下块的存储库缺少URL解决。

Some people have solved by adding below block for missing URL for repository.

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

仅举:右键单击应用程序文件夹,然后转到开放模块设置。然后移动到最后一个选项卡依赖,并通过搜索重新添加junit的。我尝试添加早期版本,但没有得到它的工作。

Just to mention : Right click on 'app' folder and goto 'Open Module Settings'. Then move to last tab 'Dependencies' and re-add junit by searching. I tried to add earlier versions but failed to get it working.