Android Studio v2.2.2错误(27,17)无法解决junit:junit4.12 [英] Android studio v2.2.2 error(27,17) failed to resolve junit:junit4.12

查看:181
本文介绍了Android Studio v2.2.2错误(27,17)无法解决junit:junit4.12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处都在搜索此答案,并尝试了多种方法来解决此问题,但是由于我是这个IDE的新手,所以我需要一点帮助.

I have searched everywhere for this answer and tried multiple ways to fix this but as I'm new to this IDE I need a little help.

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

All I have done is created an empty project in android studio and before I make changes to the files I cant build and keep coming up with 7 errors in my message gradle sync.

错误:

  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"

This is my project called 'myApplication'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的构建gradle模块:app

And this is my build gradle module: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'
}

有人可以告诉我如何处理这些错误吗?

Can someone please tell me what to do to these errors?

致谢

推荐答案

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'

还有

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

这篇关于Android Studio v2.2.2错误(27,17)无法解决junit:junit4.12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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