修复Android程序的运行时错误

时间:2016-08-03 14:56:23

标签: android

当我尝试运行一个简单的程序时,我收到了与Gradle相关的错误:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration':app:_debugUnitTestCompile'.
> Could not resolve junit:junit:4.12.
 Required by:
     MyApplication:app:unspecified
  > Could not resolve junit:junit:4.12.
     > Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
        > Could not GET 'htps://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
           > Connection to htps://jcenter.bintray.com refused .    

我不知道如何修复它,请帮助。(我目前正在使用android studio版本2.1.2) 我的模块build-gradle包含以下代码:

 apply plugin: 'com.android.application'

 android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.example.n5110.myapplication"
    minSdkVersion 15
    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.3.0'
       compile 'com.android.support:design:23.3.0'
   }

1 个答案:

答案 0 :(得分:0)

gralde.build的问题部分就是这一行:

testCompile 'junit:junit:4.12'

这是一个单元测试库。如果您刚刚开始并且可能不会为您的项目编写测试用例,则可以通过简单地删除该行来解决问题。但是,如果您基本上需要该库,请参考here