错误内容:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1.
Open File
Show Details
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.
Open File
Show Details
解决方案
1. 修改文件 build.gradle
将
dependencies {
...
}
修改为:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.4'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
2. 修改之后build可能会又出现如下错误:
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve jwriter:jwriter:2.1.1.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
再将上述部分修改为:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:0.4'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
3. 再次build之后还有可能出现以下错误:
No resource identifier found for attribute 'layout_behavior' in package
再将上述部分修改为:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:0.4'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'