Android studio v2.2.2错误(27,17)无法解析junit:junit4.12

Edg*_*l95 7 java junit android

我已经到处寻找这个答案,并尝试了多种方法来解决这个问题,但由于我是这个IDE的新手,我需要一些帮助.

我所做的就是在android studio中创建一个空项目,在我对文件进行更改之前我无法构建并在我的消息gradle sync中不断出现7个错误.

错误:

  1. (27,17)无法解决:junit:junit:4.12
  2. 无法解决:javax.inject:javax.inject:1
  3. 无法解决:javax.annotation:javax.annotation-api:1.2
  4. 无法解决:com.google.code.findbugs:jsr305:2.0.1
  5. 无法解决:org.hamcrest:hamcrest-library:1.3
  6. 无法解决:org.hamcrest:hamcrest-integration:1.3
  7. 无法解决:com.squareup:javawriter:2.1.1

这是我的项目'myApplication'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

这是我的构建gradle模块:app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "test.app.stannah.com.uk"
        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(dir: 'libs', include: ['*.jar'])
    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'
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我该怎么做这些错误?

问候

Man*_*ath 12

从中删除不需要的库build.gradle,

compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
  exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)

并且

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Run Code Online (Sandbox Code Playgroud)