无法解决:junit:junit:4.12 [英] Failed to resolve: junit:junit:4.12

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

问题描述

我刚刚在工作计算机上安装了Android Studio,并创建了一个新的空白项目.但是,我收到以下错误.

I just installed Android Studios on my work computer and I created a new blank project. However, I receive the following error.

无法解决:junit:junit:4.12

从上次提出这个问题开始,我就尝试了许多解决方案,但是似乎都没有用.我尝试注释掉整行编译文件('libs/junit-4.12.jar').我尝试将jar文件从Android studio lib文件夹复制粘贴到我的项目lib文件夹,并将其添加为库.最重要的是,构建gradle总是花费超过10分钟的时间.因此,我想尝试的任何解决方案都会花我一段时间.请帮忙.

I have attempted numerous solutions from the previous time this question was asked but none of them seem to be working. I tried commenting out the entire line compile files('libs/junit-4.12.jar'). I tried copy pasting the jar file from the Android studio lib folder to my project lib folder and adding it as a library. On top of that,the gradle always takes more than 10 minutes to build. So any solution I want to try takes me a while. Please help.

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(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: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 is a unit testing framework for Java programming language.

JUnit在测试驱动的开发中很重要 开发.

JUnit has been important in the development of test-driven development .

首先,在项目级别修改您的build.gradle

At first modify your build.gradle from Project Level

  // 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 (模块级别)部分中删除compile files('libs/junit-4.12.jar').

Duplicate

At first remove compile files('libs/junit-4.12.jar') from build.gradle ( Module Level) section .

然后 Clean-Rebuild-Gradle-Run .

Then Clean-Rebuild-Gradle-Run .

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

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