2016-11-29 40 views
0

我已經刪除了代碼行testCompile 'junit:junit:4.12',但我在運行Gradle同步時遇到此錯誤。未能解決:junit:junit:4.12,即使這樣的代碼行不存在

的build.gradle(APP)

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.1" 
    defaultConfig { 
     applicationId "com.example.bankarpranit26.myapplication002" 
     minSdkVersion 14 
     targetSdkVersion 23 
     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.1', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.1.0' 
} 

的build.gradle(項目)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter { 
      url "http://jcenter.bintray.com/" 
     } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter { 
      url "http://jcenter.bintray.com/" 
     } 
    } 
} 

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

的代碼行不存在,即使在那時我正在此錯誤。

我也收到以下錯誤:

Error:Error:Failed to resolve: junit:junit:4.12 

Error:Error:Failed to resolve: javax.inject:javax.inject:1 

Error:Error:Failed to resolve: javax.annotation:javax.annotation-api:1.2 

Error:Error:Failed to resolve: com.google.code.findbugs:jsr305:2.0.1 

Error:Error:line (26)Failed to resolve: com.android.support:appcompat-v7:25.1.0 

Error:Error:Failed to resolve: org.hamcrest:hamcrest-library:1.3 

Error:Error:Failed to resolve: org.hamcrest:hamcrest-integration:1.3 

Error:Error:Failed to resolve: com.squareup:javawriter:2.1.1 

我無法理解的這個原因。請幫忙。

+0

你應該用'jcenter()替換'jcenter {url}'塊' –

回答

0

不刪除該行只是在你的倉庫和同步添加這些行再次

android { 
    [...] 
    repositories { 
     maven { url 'http://repo1.maven.org/maven2' } 
    } 
    [...] 
} 

如果這行不通去構建>清潔工程 其他錯誤,您需要編譯其他librararies如

compile 'javax.inject:javax.inject:[email protected]' 
com.android.support:appcompat-v7:25.1.0' 
相關問題