我删除了代码行testCompile 'junit:junit:4.12'
,但在运行Gradle同步时仍然出现此错误。
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(Project)
// 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 :(得分:0)
请勿删除该行,只需在存储库中添加这些行并再次同步
--------------
Canton , Mary Lená Pettiet , 33 , Female , White
--------------
Canton , Mary Lená Pettiet , 33 , Female , White
如果这不起作用去构建>清理项目 对于其他错误,您需要编译其他库,如
android {
[...]
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
[...]
}