首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未能解决: junit:junit:4.12

未能解决: junit:junit:4.12
EN

Stack Overflow用户
提问于 2016-10-13 19:45:52
回答 2查看 9.9K关注 0票数 1

我刚刚在我的工作电脑上安装了Android工作室,我创建了一个新的空白项目。但是,我收到以下错误。

未能解决: junit:junit:4.12

从上一次提出这个问题以来,我曾尝试过许多解决办法,但似乎没有一种解决办法奏效。我试着注释掉整个编译文件(‘libs/junit-4.12.jar’)。我尝试将jar文件从文件夹粘贴到我的项目库文件夹中,并将其添加为一个库。最重要的是,压舱的建造时间总是超过10分钟。所以我想尝试的任何解决方案都需要我一段时间。请帮帮忙。

代码语言:javascript
复制
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)

代码语言:javascript
复制
// 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
}
EN

回答 2

Stack Overflow用户

发布于 2016-10-14 05:24:58

JUnit是一个面向Java编程语言的单元测试框架。

JUnit在开发测试驱动的开发中一直很重要。

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

代码语言:javascript
复制
  // 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
}

复制

首先,将compile files('libs/junit-4.12.jar')build.gradle (模块级)部分中删除。

然后是Clean-Rebuild-Gradle-Run

票数 3
EN

Stack Overflow用户

发布于 2016-10-13 20:49:30

尝试将mavenCentral()添加为存储库,并删除compile files('libs/junit-4.12.jar')

代码语言:javascript
复制
buildscript {
    ...
    repositories {
        mavenCentral()
    }
    ...
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40029657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档