gpt4 book ai didi

android - Gradle 同步失败 : Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'

转载 作者:行者123 更新时间:2023-11-29 15:00:06 35 4
gpt4 key购买 nike

我最近将我的 Android Studio 更新到 3.0.1 版,并开始了一个包含空白 Activity 的新项目。一旦 gradle 同步开始(只要我打开项目),我就会在事件日志中收到一条消息:

Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.android.support:appcompat-v7:26.1.0
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
Connect to dl.google.com:443 [dl.google.com/216.58.197.46] failed: Connection refused: connect
Connection refused: connect
Consult IDE log for more details (Help | Show Log) (3s 878ms)

我从 Android SDK 管理器重新安装了支持存储库并将 maven 添加到依赖项,但到目前为止还无法解决问题。

构建等级:

// 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.0.1'

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

allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
}
}

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

应用级构建-gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.vishalbisht.test"
minSdkVersion 15
targetSdkVersion 26
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:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}

最佳答案

我能够通过在应用程序级 build-gradle 中评论以下行来解决这个问题

   androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'

然后它开始工作,不确定这是否是一个可接受的解决方案,但据我所知,我至少可以运行和编译我的代码。

同样在Android studio 3.1更新之后,我也没有遇到过这个问题。

关于android - Gradle 同步失败 : Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47827087/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com