这是我第一次在android studio中创建一个新项目。然后,在将构建工具添加到27.0.3并检查了设置中的“启用嵌入式Maven存储库”后,出现了此类错误。谁能帮我解决这个问题?谢谢。
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.">Show Details</a>
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath':
Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.">Show Details</a>
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a
href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.">Show Details</a>
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.">Show Details</a>
这是我的文件build.gradle(项目:HelloWorldApp)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的(Module:app)文件build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.abc.helloworldapp"
minSdkVersion 15
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'
}
答案 0 :(得分:0)
这是API问题,请将其更改为27,如果未安装27,则可以通过Studio更新。要从Android Studio打开SDK Manager,请依次点击工具> SDK Manager或单击SDK Manager并安装所需的软件包。
像这样更改代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.abc.helloworldapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:27.1.1'
}
希望这会起作用。
答案 1 :(得分:0)
这是由于gradle
或互联网连接。
尝试将您的gradle
更新为3.2.0
版本:
classpath 'com.android.tools.build:gradle:3.2.0'
在您的root of project -> Build.gradle
中有buildscript - dependencies
的地方。您可以在classpath
中包含dependencies
的文件中找到它。在Android Studio中称为project/yourprojectname
。
答案 2 :(得分:0)
有时它会在无法连接到所需服务器时发生,因此您必须验证一些事情。 1.您必须验证您是否具有网络连接。 2.您必须验证是否可以连接到特定服务器,因此请尝试使用某些VPN。 3.确认您的gradle在线,要在Mac和Windows上转到首选项,我认为它将是Settings == Gradle。
答案 3 :(得分:0)
很长一段时间以来,我一直坚持这种问题,在仔细观察问题后终于解决了这个问题,这表明
无法解决':app @ debug / compileClasspath'的依赖关系
您需要确定并仔细检查该类是否位于该类中。我猜想这件事将对许多人有很大帮助,因为专注于这一点使我更接近解决方案。
谢谢