求教!刚装好的Android studio,做 一测试工程,就出现一大堆 Unable to resolve dependency for 的问题
求教!刚装好的Android studio,做 一测试工程,就出现一大堆 Unable to resolve dependency for ':app@debug/compileClasspath':的问题
【错误提示】
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Open File
Show Details
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Open File
Show Details
还有好多这样的错误。
【关于代理和镜像】
我没有在SDK Update Sites 里设定国内镜像,但修改了hosts文件,好像 dl.谷gle.com 都能正常下载。
【修改尝试方法1】
试了很多办法,有人说,把 build.gradle 文件第一行
apply plugin: 'com.android.application'
改成
apply plugin: 'com.android.library'
但改完之后编译,又多出现了错误:
Library projects cannot set applicationId. applicationId is set to 'com.test.myapplication3' in default config.
【修改尝试方法2】
我下载安装了 gradle-4.10.2-bin.zip,命令行输入“gradle -v”,能正常显示“gradle 4.10.2”
把 gradle-wrapper.properties 文件改成这样
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
只是在“C:\Users\用户\.gradle\wrapper\dists”里下载了gradle-4.10-all.zip,
好多Unable to resolve dependency for错误还是存在
【文件设定内容】
我 build.gradle 的内容是 Android studio 自动创建的:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.test.myapplication4"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
下面的几个依赖文件多出错了。
非常感谢!